From 316b31002ff1dfa5a7a738990a41be5edc099bb6 Mon Sep 17 00:00:00 2001 From: Yao Cui Date: Thu, 29 Aug 2024 19:34:12 +0000 Subject: [PATCH 1/4] Minimum generator change. Mix location, iampolicy, lro into datamigration service --- generator/CMakeLists.txt | 2 + generator/google_cloud_cpp_generator.bzl | 2 + .../v1/internal/golden_kitchen_sink_stub.h | 2 +- .../v1/internal/golden_thing_admin_stub.h | 8 +- .../golden/v1/internal/request_id_stub.h | 8 +- .../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 | 20 +- 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 | 63 ++- 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 +- generator/internal/http_option_utils.cc | 84 ++-- generator/internal/http_option_utils.h | 13 +- generator/internal/http_option_utils_test.cc | 60 +-- .../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/longrunning.cc | 13 +- generator/internal/make_generators.cc | 98 ++-- .../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 | 155 ++++++ generator/internal/mixin_utils.h | 53 ++ .../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 | 25 +- 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 | 45 +- generator/internal/stub_factory_generator.h | 4 +- .../internal/stub_factory_rest_generator.cc | 11 +- .../internal/stub_factory_rest_generator.h | 3 +- generator/internal/stub_generator.cc | 180 ++++--- generator/internal/stub_generator.h | 4 +- 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 | 15 + google/cloud/datamigration/BUILD.bazel | 2 + .../datamigration/quickstart/MODULE.bazel | 6 + .../datamigration/quickstart/quickstart.cc | 37 ++ .../datamigration/v1/data_migration_client.cc | 95 ++++ .../datamigration/v1/data_migration_client.h | 452 ++++++++++++++++++ .../v1/data_migration_connection.cc | 54 +++ .../v1/data_migration_connection.h | 27 ++ ...migration_connection_idempotency_policy.cc | 46 ++ ..._migration_connection_idempotency_policy.h | 30 ++ .../internal/data_migration_auth_decorator.cc | 76 +++ .../internal/data_migration_auth_decorator.h | 36 ++ .../data_migration_connection_impl.cc | 165 +++++++ .../internal/data_migration_connection_impl.h | 27 ++ .../data_migration_logging_decorator.cc | 104 ++++ .../data_migration_logging_decorator.h | 36 ++ .../data_migration_metadata_decorator.cc | 80 ++++ .../data_migration_metadata_decorator.h | 36 ++ .../v1/internal/data_migration_stub.cc | 105 ++++ .../v1/internal/data_migration_stub.h | 92 +++- .../internal/data_migration_stub_factory.cc | 11 +- .../data_migration_tracing_connection.cc | 83 ++++ .../data_migration_tracing_connection.h | 27 ++ .../internal/data_migration_tracing_stub.cc | 104 ++++ .../v1/internal/data_migration_tracing_stub.h | 36 ++ .../v1/mocks/mock_data_migration_connection.h | 36 ++ google/cloud/pubsub/quickstart/MODULE.bazel | 6 + 105 files changed, 2690 insertions(+), 309 deletions(-) create mode 100644 generator/internal/mixin_utils.cc create mode 100644 generator/internal/mixin_utils.h create mode 100644 google/cloud/datamigration/quickstart/MODULE.bazel create mode 100644 google/cloud/pubsub/quickstart/MODULE.bazel 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/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/auth_decorator_generator.cc b/generator/internal/auth_decorator_generator.cc index 92d73b1e62174..7fa235742f85e 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 47ae3849623ec..6c7224500ceec 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 901d8db65a785..9d2aa81503aff 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 { @@ -29,10 +30,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()); @@ -68,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/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 328cf76cc1638..a94c54217a7c4 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 cbe96af4b58c8..ee14f6e6a2e04 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 c81cb34007827..5703b6b98cf8f 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 4a7c1239972af..d14270ba0a6d8 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 72fd7862fc1f4..56a05dc0682d3 100644 --- a/generator/internal/descriptor_utils.cc +++ b/generator/internal/descriptor_utils.cc @@ -455,6 +455,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"}. @@ -559,7 +571,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"]); @@ -692,6 +705,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"] = @@ -802,7 +819,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 {}; @@ -842,7 +860,46 @@ 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); + 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()); + method_vars["return_type"] = + IsResponseTypeEmpty(method) + ? "Status" + : absl::StrFormat("StatusOr<%s>", method_vars.at("response_type")); + 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, 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/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 6f72a61646e35..c675265660579 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/http_option_utils.cc b/generator/internal/http_option_utils.cc index 2687ec47a7216..8c5b45fb997fa 100644 --- a/generator/internal/http_option_utils.cc +++ b/generator/internal/http_option_utils.cc @@ -263,7 +263,9 @@ void SetHttpQueryParameters(HttpExtensionInfo const& info, } HttpExtensionInfo ParseHttpExtension( - google::protobuf::MethodDescriptor const& method) { + google::protobuf::MethodDescriptor const& method, + google::protobuf::ServiceDescriptor const& service, + absl::optional method_override) { if (!method.options().HasExtension(google::api::http)) return {}; HttpExtensionInfo info; @@ -271,30 +273,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); @@ -322,8 +329,10 @@ 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(service); auto rest_path_visitor = RestPathVisitor(api_version, info.rest_path); for (auto const& s : parsed_http_rule->segments) { @@ -345,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(); } @@ -395,10 +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. -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) { @@ -406,9 +426,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 1d9975d432fa2..16286563b39b3 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,9 @@ struct HttpExtensionInfo { * transcoding and REST transport. */ HttpExtensionInfo ParseHttpExtension( - google::protobuf::MethodDescriptor const& method); + google::protobuf::MethodDescriptor const& method, + google::protobuf::ServiceDescriptor const& service, + absl::optional method_override = absl::nullopt); /** * Sets the following method_vars based on the provided parsed_http_info: @@ -112,11 +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. */ -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..2e5ed4714bfca 100644 --- a/generator/internal/http_option_utils_test.cc +++ b/generator/internal/http_option_utils_test.cc @@ -36,6 +36,7 @@ using ::testing::ElementsAre; using ::testing::Eq; using ::testing::HasSubstr; using ::testing::IsEmpty; +using ::testing::Optional; using ::testing::Pair; char const* const kHttpProto = @@ -434,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, @@ -449,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"))); @@ -463,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( @@ -478,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/*"))); @@ -491,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("")); @@ -504,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")); @@ -518,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"), @@ -534,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("*")); @@ -554,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=\", " @@ -576,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( @@ -593,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("")); } @@ -603,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("")); } @@ -613,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"), @@ -628,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( @@ -728,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")); } @@ -738,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()")); } @@ -748,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_()")); } @@ -773,22 +782,17 @@ 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/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 69cef994b6c7e..dde8fad017019 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 ae0f4bd08f36f..b44dad02b367d 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/longrunning.cc b/generator/internal/longrunning.cc index d8aef984ca6af..6634508f9b427 100644 --- a/generator/internal/longrunning.cc +++ b/generator/internal/longrunning.cc @@ -75,12 +75,8 @@ DeduceLongrunningOperationResponseType( } // namespace bool IsLongrunningOperation(MethodDescriptor const& method) { - bool grpc_lro = - method.output_type()->full_name() == "google.longrunning.Operation"; - auto operation_service_extension = - method.options().GetExtension(google::cloud::operation_service); - bool http_lro = !operation_service_extension.empty(); - return grpc_lro || http_lro; + return IsGRPCLongrunningOperation(method) || + IsHttpLongrunningOperation(method); } bool IsLongrunningMetadataTypeUsedAsResponse(MethodDescriptor const& method) { @@ -95,6 +91,8 @@ bool IsLongrunningMetadataTypeUsedAsResponse(MethodDescriptor const& method) { void SetLongrunningOperationMethodVars( google::protobuf::MethodDescriptor const& method, VarsDictionary& method_vars) { + if (!IsLongrunningOperation(method)) return; + method_vars["longrunning_operation_type"] = ProtoNameToCppName(method.output_type()->full_name()); @@ -136,7 +134,8 @@ void SetLongrunningOperationMethodVars( } bool IsGRPCLongrunningOperation(MethodDescriptor const& method) { - return method.output_type()->full_name() == "google.longrunning.Operation"; + return method.output_type()->full_name() == "google.longrunning.Operation" && + method.options().HasExtension(google::longrunning::operation_info); } bool IsHttpLongrunningOperation(MethodDescriptor const& method) { diff --git a/generator/internal/make_generators.cc b/generator/internal/make_generators.cc index a27248353feb6..1cc109193e731 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,44 @@ 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") { + mixin_methods = GetMixinMethods(service_config, *service); + 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 << "###########################################" << 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); + if (service->name() == "DataMigrationService") { + std::cout << "###########################################@@" << std::endl; + for (auto& x : method_vars) { + if (x.first != "google.longrunning.Operations.GetOperation") continue; + + std::cout << x.first << " : " << x.second["response_type"] << " : " + << x.second["return_type"] << " : " + << x.second["longrunning_deduced_response_type"] << std::endl; + } + std::cout << "###########################################@@" << std::endl; + } 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 +110,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 +183,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 +230,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 28d9410f82857..b250454086cb1 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 ba6a664a2da90..b11eb794dedcb 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..734c82fc14b85 --- /dev/null +++ b/generator/internal/mixin_utils.cc @@ -0,0 +1,155 @@ +#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 +#include +#include +#include +#include +#include + +using ::google::protobuf::DescriptorPool; +using ::google::protobuf::FileDescriptor; +using ::google::protobuf::MethodDescriptor; +using ::google::protobuf::ServiceDescriptor; + +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_map http_verbs = { + {"get", "Get"}, {"post", "Post"}, {"put", "Put"}, + {"patch", "Patch"}, {"delete", "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; + 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"]; + 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 = 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; + 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_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); + method_names.insert(method->name()); + } + return method_names; +} + +} // 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(); + } + std::unordered_set const method_names = GetMethodNames(service); + auto mixin_proto_paths = GetMixinProtoPaths(service_config); + 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); + 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; + + 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, + 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..45bc7c7aad722 --- /dev/null +++ b/generator/internal/mixin_utils.h @@ -0,0 +1,53 @@ +// 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 "absl/types/optional.h" +#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; +}; + +struct MixinMethod { + std::string grpc_stub_name; + std::string grpc_stub_fqn; + 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 5870ad30d1f80..cef641e3ed9bb 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 87d0d3a66c379..12ebe514c5eda 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..fbede7a411710 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,10 @@ void ServiceCodeGenerator::SetMethods() { async_methods_.emplace_back(*method); } } + + for (auto const& mixin_method : mixin_methods_) { + methods_.emplace_back(mixin_method.method.get()); + } } std::string ServiceCodeGenerator::GetPbIncludeByTransport() const { @@ -481,6 +489,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..139258cfd2a4e 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 { @@ -25,10 +26,13 @@ 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), + mixin_methods_(mixin_methods) {} Status StubFactoryGenerator::GenerateHeader() { HeaderPrint(CopyrightLicenseFileHeader()); @@ -84,11 +88,30 @@ 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; + 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$> @@ -99,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 8dba8d26b5773..7feb7040614be 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; @@ -49,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_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 c96ef7b1e5174..c601d5ddff302 100644 --- a/generator/internal/stub_generator.cc +++ b/generator/internal/stub_generator.cc @@ -19,8 +19,10 @@ #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 namespace google { namespace cloud { @@ -30,10 +32,12 @@ 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), + mixin_methods_(mixin_methods) {} Status StubGenerator::GenerateHeader() { HeaderPrint(CopyrightLicenseFileHeader()); @@ -72,6 +76,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" : "", @@ -211,33 +218,58 @@ Status StubGenerator::GenerateHeader() { "\n" "class Default$stub_class_name$ : public $stub_class_name$ {\n" " public:"); + + 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( + absl::StrCat(R"""( + explicit Default$stub_class_name$( + 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(); // 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"); @@ -290,11 +322,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$>> @@ -302,17 +344,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$>> @@ -323,14 +366,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, @@ -343,13 +388,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, @@ -357,70 +404,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$( @@ -431,15 +491,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$( @@ -449,15 +510,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, @@ -471,17 +534,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, @@ -495,11 +560,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/generator/internal/stub_generator.h b/generator/internal/stub_generator.h index b972b32af6fbe..3f1c3df3c6f61 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; @@ -50,6 +51,7 @@ class StubGenerator : public StubGeneratorBase { private: Status GenerateHeader() override; Status GenerateCc() override; + std::vector mixin_methods_; }; } // namespace generator_internal diff --git a/generator/internal/stub_generator_base.cc b/generator/internal/stub_generator_base.cc index caeb98632378d..058948d081e80 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 ef3bfb0421a2f..c8892b9bc6816 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 77ac65eedbce4..1afea7c3997cb 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 0a1460c9dd1b2..ca5c1e3f98d35 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 ded91de8245e5..f48aaab69b27e 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..de2b2dc18cbaa 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,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; } GCP_LOG(INFO) << "Generating service code using: " diff --git a/google/cloud/datamigration/BUILD.bazel b/google/cloud/datamigration/BUILD.bazel index 2e50d98b52e8b..2905f872556eb 100644 --- a/google/cloud/datamigration/BUILD.bazel +++ b/google/cloud/datamigration/BUILD.bazel @@ -26,6 +26,8 @@ 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", + "@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 8f4dae71d95d9..46fa0eaa4a55d 100644 --- a/google/cloud/datamigration/quickstart/quickstart.cc +++ b/google/cloud/datamigration/quickstart/quickstart.cc @@ -29,11 +29,48 @@ 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"; + + std::cout + << "------------------------TEST ListOperations------------------------" + << std::endl; + + for (auto l : + client.ListOperations("projects/" + std::string(argv[1]) + + "/locations/" + argv[2] + "/operations", + "")) { + if (!l) throw std::move(l).status(); + std::cout << l->DebugString() << "\n"; + } + return 0; } catch (google::cloud::Status const& status) { std::cerr << "google::cloud::Status thrown: " << status << "\n"; diff --git a/google/cloud/datamigration/v1/data_migration_client.cc b/google/cloud/datamigration/v1/data_migration_client.cc index 7abc948a2e3b9..07012d43394fc 100644 --- a/google/cloud/datamigration/v1/data_migration_client.cc +++ b/google/cloud/datamigration/v1/data_migration_client.cc @@ -1110,6 +1110,101 @@ 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); +} + +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); +} + +StreamRange +DataMigrationServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +DataMigrationServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +DataMigrationServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +DataMigrationServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status DataMigrationServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status DataMigrationServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status DataMigrationServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status DataMigrationServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..6491cdae7b500 100644 --- a/google/cloud/datamigration/v1/data_migration_client.h +++ b/google/cloud/datamigration/v1/data_migration_client.h @@ -3273,6 +3273,458 @@ 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 = {}); + + // 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..6e46a63b553df 100644 --- a/google/cloud/datamigration/v1/data_migration_connection.cc +++ b/google/cloud/datamigration/v1/data_migration_connection.cc @@ -704,6 +704,60 @@ 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"); +} + +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"); +} + +StreamRange +DataMigrationServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +DataMigrationServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DataMigrationServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DataMigrationServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDataMigrationServiceConnection(Options options) { internal::CheckExpectedOptions FetchStaticIps( google::cloud::clouddms::v1::FetchStaticIpsRequest 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..51f0f2b8ba017 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,52 @@ 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; +} + +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; +} + +Idempotency DataMigrationServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DataMigrationServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DataMigrationServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency DataMigrationServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..aece26df12a81 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,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -175,6 +178,33 @@ 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); + + 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..902bcf9b69935 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,82 @@ 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); +} + +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); +} + +StatusOr +DataMigrationServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr DataMigrationServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status DataMigrationServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status DataMigrationServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..a68f05bcef3f3 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,42 @@ 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; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..892ba366dcb08 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,171 @@ 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__); +} + +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__); +} + +StreamRange +DataMigrationServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DataMigrationServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DataMigrationServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DataMigrationServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..f8590abbd190c 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,33 @@ 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; + + 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..28adce0a2aa17 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,110 @@ 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_); +} + +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_); +} + +StatusOr +DataMigrationServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataMigrationServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DataMigrationServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DataMigrationServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..d93993e2116e4 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,42 @@ 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; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..f9c664ab5aab2 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,86 @@ 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); +} + +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); +} + +StatusOr +DataMigrationServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +DataMigrationServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status DataMigrationServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status DataMigrationServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..532aca3c38b57 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,42 @@ 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; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..5bd4721bf5eb0 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_stub.cc +++ b/google/cloud/datamigration/v1/internal/data_migration_stub.cc @@ -1018,6 +1018,111 @@ 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 = locations_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 = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + 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; +} + +StatusOr +DefaultDataMigrationServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataMigrationServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultDataMigrationServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultDataMigrationServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..6f8436a5cf55d 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_stub.h +++ b/google/cloud/datamigration/v1/internal/data_migration_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -431,6 +433,44 @@ 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 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -450,9 +490,18 @@ class DefaultDataMigrationServiceStub : public DataMigrationServiceStub { std::unique_ptr< google::cloud::clouddms::v1::DataMigrationService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListMigrationJobs(grpc::ClientContext& context, Options const& options, @@ -835,6 +884,42 @@ 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; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -851,6 +936,11 @@ class DefaultDataMigrationServiceStub : public DataMigrationServiceStub { std::unique_ptr< google::cloud::clouddms::v1::DataMigrationService::StubInterface> grpc_stub_; + std::unique_ptr + operations_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 bb3630665cb4f..b1018c82d7270 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,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultDataMigrationServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::clouddms::v1::DataMigrationService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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 ed63cbb3af2cd..236e26b6cc244 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,89 @@ 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)); +} + +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)); +} + +StreamRange +DataMigrationServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "datamigration_v1::DataMigrationServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DataMigrationServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "datamigration_v1::DataMigrationServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status DataMigrationServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "datamigration_v1::DataMigrationServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status DataMigrationServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "datamigration_v1::DataMigrationServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..bdc6c1466c642 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,33 @@ 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; + + 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..32662986945db 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,110 @@ 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)); +} + +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)); +} + +StatusOr +DataMigrationServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.clouddms.v1.DataMigrationService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +DataMigrationServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.clouddms.v1.DataMigrationService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status DataMigrationServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.clouddms.v1.DataMigrationService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status DataMigrationServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.clouddms.v1.DataMigrationService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..2e51226287ccb 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,42 @@ 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; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..5bea3a9ea0ec4 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,42 @@ 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)); + + 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END 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 +############################################################################### From b3b310404e663c9d7579651c1b9b44511c28cce3 Mon Sep 17 00:00:00 2001 From: Yao Cui Date: Thu, 29 Aug 2024 20:00:19 +0000 Subject: [PATCH 2/4] Mix location, iampolicy, lro into all services. --- generator/internal/make_generators.cc | 14 +- .../v1/access_context_manager_client.cc | 16 + .../v1/access_context_manager_client.h | 60 +++ .../v1/access_context_manager_connection.cc | 6 + .../v1/access_context_manager_connection.h | 3 + ...t_manager_connection_idempotency_policy.cc | 5 + ...xt_manager_connection_idempotency_policy.h | 4 + .../access_context_manager_auth_decorator.cc | 8 + .../access_context_manager_auth_decorator.h | 4 + .../access_context_manager_connection_impl.cc | 14 + .../access_context_manager_connection_impl.h | 3 + ...ccess_context_manager_logging_decorator.cc | 12 + ...access_context_manager_logging_decorator.h | 4 + ...cess_context_manager_metadata_decorator.cc | 9 + ...ccess_context_manager_metadata_decorator.h | 4 + .../internal/access_context_manager_stub.cc | 12 + .../v1/internal/access_context_manager_stub.h | 16 +- .../access_context_manager_stub_factory.cc | 5 +- ...cess_context_manager_tracing_connection.cc | 9 + ...ccess_context_manager_tracing_connection.h | 3 + .../access_context_manager_tracing_stub.cc | 13 + .../access_context_manager_tracing_stub.h | 4 + .../mock_access_context_manager_connection.h | 4 + google/cloud/aiplatform/BUILD.bazel | 2 + google/cloud/aiplatform/v1/dataset_client.cc | 97 ++++ google/cloud/aiplatform/v1/dataset_client.h | 491 +++++++++++++++++ .../cloud/aiplatform/v1/dataset_connection.cc | 59 +++ .../cloud/aiplatform/v1/dataset_connection.h | 30 ++ .../dataset_connection_idempotency_policy.cc | 51 ++ .../dataset_connection_idempotency_policy.h | 33 ++ .../v1/deployment_resource_pool_client.cc | 104 ++++ .../v1/deployment_resource_pool_client.h | 492 ++++++++++++++++++ .../v1/deployment_resource_pool_connection.cc | 62 +++ .../v1/deployment_resource_pool_connection.h | 30 ++ ...urce_pool_connection_idempotency_policy.cc | 61 +++ ...ource_pool_connection_idempotency_policy.h | 33 ++ google/cloud/aiplatform/v1/endpoint_client.cc | 97 ++++ google/cloud/aiplatform/v1/endpoint_client.h | 491 +++++++++++++++++ .../aiplatform/v1/endpoint_connection.cc | 60 +++ .../cloud/aiplatform/v1/endpoint_connection.h | 30 ++ .../endpoint_connection_idempotency_policy.cc | 51 ++ .../endpoint_connection_idempotency_policy.h | 33 ++ .../v1/feature_online_store_admin_client.cc | 104 ++++ .../v1/feature_online_store_admin_client.h | 491 +++++++++++++++++ .../feature_online_store_admin_connection.cc | 62 +++ .../feature_online_store_admin_connection.h | 30 ++ ...ore_admin_connection_idempotency_policy.cc | 61 +++ ...tore_admin_connection_idempotency_policy.h | 33 ++ .../v1/feature_online_store_client.cc | 102 ++++ .../v1/feature_online_store_client.h | 492 ++++++++++++++++++ .../v1/feature_online_store_connection.cc | 63 +++ .../v1/feature_online_store_connection.h | 31 ++ ...ine_store_connection_idempotency_policy.cc | 55 ++ ...line_store_connection_idempotency_policy.h | 33 ++ .../aiplatform/v1/feature_registry_client.cc | 102 ++++ .../aiplatform/v1/feature_registry_client.h | 491 +++++++++++++++++ .../v1/feature_registry_connection.cc | 62 +++ .../v1/feature_registry_connection.h | 30 ++ ..._registry_connection_idempotency_policy.cc | 52 ++ ...e_registry_connection_idempotency_policy.h | 33 ++ .../aiplatform/v1/featurestore_client.cc | 101 ++++ .../cloud/aiplatform/v1/featurestore_client.h | 491 +++++++++++++++++ .../aiplatform/v1/featurestore_connection.cc | 60 +++ .../aiplatform/v1/featurestore_connection.h | 30 ++ ...turestore_connection_idempotency_policy.cc | 51 ++ ...aturestore_connection_idempotency_policy.h | 33 ++ .../v1/featurestore_online_serving_client.cc | 103 ++++ .../v1/featurestore_online_serving_client.h | 492 ++++++++++++++++++ .../featurestore_online_serving_connection.cc | 63 +++ .../featurestore_online_serving_connection.h | 30 ++ ...e_serving_connection_idempotency_policy.cc | 61 +++ ...ne_serving_connection_idempotency_policy.h | 33 ++ .../aiplatform/v1/gen_ai_tuning_client.cc | 100 ++++ .../aiplatform/v1/gen_ai_tuning_client.h | 491 +++++++++++++++++ .../aiplatform/v1/gen_ai_tuning_connection.cc | 60 +++ .../aiplatform/v1/gen_ai_tuning_connection.h | 30 ++ ...ai_tuning_connection_idempotency_policy.cc | 51 ++ ..._ai_tuning_connection_idempotency_policy.h | 33 ++ google/cloud/aiplatform/v1/index_client.cc | 95 ++++ google/cloud/aiplatform/v1/index_client.h | 491 +++++++++++++++++ .../cloud/aiplatform/v1/index_connection.cc | 57 ++ google/cloud/aiplatform/v1/index_connection.h | 30 ++ .../v1/index_connection_idempotency_policy.cc | 51 ++ .../v1/index_connection_idempotency_policy.h | 33 ++ .../aiplatform/v1/index_endpoint_client.cc | 102 ++++ .../aiplatform/v1/index_endpoint_client.h | 491 +++++++++++++++++ .../v1/index_endpoint_connection.cc | 60 +++ .../aiplatform/v1/index_endpoint_connection.h | 30 ++ ..._endpoint_connection_idempotency_policy.cc | 51 ++ ...x_endpoint_connection_idempotency_policy.h | 33 ++ .../v1/internal/dataset_auth_decorator.cc | 83 +++ .../v1/internal/dataset_auth_decorator.h | 40 ++ .../v1/internal/dataset_connection_impl.cc | 175 +++++++ .../v1/internal/dataset_connection_impl.h | 30 ++ .../v1/internal/dataset_logging_decorator.cc | 113 ++++ .../v1/internal/dataset_logging_decorator.h | 40 ++ .../v1/internal/dataset_metadata_decorator.cc | 85 +++ .../v1/internal/dataset_metadata_decorator.h | 40 ++ .../aiplatform/v1/internal/dataset_stub.cc | 117 +++++ .../aiplatform/v1/internal/dataset_stub.h | 100 +++- .../v1/internal/dataset_stub_factory.cc | 11 +- .../v1/internal/dataset_tracing_connection.cc | 90 ++++ .../v1/internal/dataset_tracing_connection.h | 30 ++ .../v1/internal/dataset_tracing_stub.cc | 116 +++++ .../v1/internal/dataset_tracing_stub.h | 40 ++ ...deployment_resource_pool_auth_decorator.cc | 88 ++++ .../deployment_resource_pool_auth_decorator.h | 40 ++ ...eployment_resource_pool_connection_impl.cc | 179 +++++++ ...deployment_resource_pool_connection_impl.h | 30 ++ ...loyment_resource_pool_logging_decorator.cc | 118 +++++ ...ployment_resource_pool_logging_decorator.h | 40 ++ ...oyment_resource_pool_metadata_decorator.cc | 90 ++++ ...loyment_resource_pool_metadata_decorator.h | 40 ++ .../internal/deployment_resource_pool_stub.cc | 119 +++++ .../internal/deployment_resource_pool_stub.h | 100 +++- .../deployment_resource_pool_stub_factory.cc | 11 +- ...oyment_resource_pool_tracing_connection.cc | 95 ++++ ...loyment_resource_pool_tracing_connection.h | 30 ++ .../deployment_resource_pool_tracing_stub.cc | 128 +++++ .../deployment_resource_pool_tracing_stub.h | 40 ++ .../v1/internal/endpoint_auth_decorator.cc | 83 +++ .../v1/internal/endpoint_auth_decorator.h | 40 ++ .../v1/internal/endpoint_connection_impl.cc | 175 +++++++ .../v1/internal/endpoint_connection_impl.h | 30 ++ .../v1/internal/endpoint_logging_decorator.cc | 113 ++++ .../v1/internal/endpoint_logging_decorator.h | 40 ++ .../internal/endpoint_metadata_decorator.cc | 86 +++ .../v1/internal/endpoint_metadata_decorator.h | 40 ++ .../aiplatform/v1/internal/endpoint_stub.cc | 117 +++++ .../aiplatform/v1/internal/endpoint_stub.h | 100 +++- .../v1/internal/endpoint_stub_factory.cc | 11 +- .../internal/endpoint_tracing_connection.cc | 92 ++++ .../v1/internal/endpoint_tracing_connection.h | 30 ++ .../v1/internal/endpoint_tracing_stub.cc | 116 +++++ .../v1/internal/endpoint_tracing_stub.h | 40 ++ ...ature_online_store_admin_auth_decorator.cc | 88 ++++ ...eature_online_store_admin_auth_decorator.h | 40 ++ ...ture_online_store_admin_connection_impl.cc | 179 +++++++ ...ature_online_store_admin_connection_impl.h | 30 ++ ...re_online_store_admin_logging_decorator.cc | 118 +++++ ...ure_online_store_admin_logging_decorator.h | 40 ++ ...e_online_store_admin_metadata_decorator.cc | 90 ++++ ...re_online_store_admin_metadata_decorator.h | 40 ++ .../feature_online_store_admin_stub.cc | 119 +++++ .../feature_online_store_admin_stub.h | 100 +++- ...feature_online_store_admin_stub_factory.cc | 11 +- ...e_online_store_admin_tracing_connection.cc | 96 ++++ ...re_online_store_admin_tracing_connection.h | 30 ++ ...feature_online_store_admin_tracing_stub.cc | 128 +++++ .../feature_online_store_admin_tracing_stub.h | 40 ++ .../feature_online_store_auth_decorator.cc | 86 +++ .../feature_online_store_auth_decorator.h | 40 ++ .../feature_online_store_connection_impl.cc | 180 +++++++ .../feature_online_store_connection_impl.h | 31 ++ .../feature_online_store_logging_decorator.cc | 118 +++++ .../feature_online_store_logging_decorator.h | 40 ++ ...feature_online_store_metadata_decorator.cc | 90 ++++ .../feature_online_store_metadata_decorator.h | 40 ++ .../v1/internal/feature_online_store_stub.cc | 119 +++++ .../v1/internal/feature_online_store_stub.h | 102 +++- .../feature_online_store_stub_factory.cc | 11 +- ...feature_online_store_tracing_connection.cc | 93 ++++ .../feature_online_store_tracing_connection.h | 30 ++ .../feature_online_store_tracing_stub.cc | 121 +++++ .../feature_online_store_tracing_stub.h | 40 ++ .../feature_registry_auth_decorator.cc | 86 +++ .../feature_registry_auth_decorator.h | 40 ++ .../feature_registry_connection_impl.cc | 179 +++++++ .../feature_registry_connection_impl.h | 30 ++ .../feature_registry_logging_decorator.cc | 116 +++++ .../feature_registry_logging_decorator.h | 40 ++ .../feature_registry_metadata_decorator.cc | 88 ++++ .../feature_registry_metadata_decorator.h | 40 ++ .../v1/internal/feature_registry_stub.cc | 119 +++++ .../v1/internal/feature_registry_stub.h | 100 +++- .../internal/feature_registry_stub_factory.cc | 11 +- .../feature_registry_tracing_connection.cc | 92 ++++ .../feature_registry_tracing_connection.h | 30 ++ .../internal/feature_registry_tracing_stub.cc | 119 +++++ .../internal/feature_registry_tracing_stub.h | 40 ++ .../internal/featurestore_auth_decorator.cc | 84 +++ .../v1/internal/featurestore_auth_decorator.h | 40 ++ .../internal/featurestore_connection_impl.cc | 177 +++++++ .../internal/featurestore_connection_impl.h | 30 ++ .../featurestore_logging_decorator.cc | 116 +++++ .../internal/featurestore_logging_decorator.h | 40 ++ .../featurestore_metadata_decorator.cc | 88 ++++ .../featurestore_metadata_decorator.h | 40 ++ ...turestore_online_serving_auth_decorator.cc | 88 ++++ ...aturestore_online_serving_auth_decorator.h | 40 ++ ...urestore_online_serving_connection_impl.cc | 180 +++++++ ...turestore_online_serving_connection_impl.h | 30 ++ ...estore_online_serving_logging_decorator.cc | 118 +++++ ...restore_online_serving_logging_decorator.h | 40 ++ ...store_online_serving_metadata_decorator.cc | 90 ++++ ...estore_online_serving_metadata_decorator.h | 40 ++ .../featurestore_online_serving_stub.cc | 119 +++++ .../featurestore_online_serving_stub.h | 102 +++- ...eaturestore_online_serving_stub_factory.cc | 11 +- ...store_online_serving_tracing_connection.cc | 101 ++++ ...estore_online_serving_tracing_connection.h | 30 ++ ...eaturestore_online_serving_tracing_stub.cc | 128 +++++ ...featurestore_online_serving_tracing_stub.h | 40 ++ .../v1/internal/featurestore_stub.cc | 117 +++++ .../v1/internal/featurestore_stub.h | 100 +++- .../v1/internal/featurestore_stub_factory.cc | 11 +- .../featurestore_tracing_connection.cc | 92 ++++ .../featurestore_tracing_connection.h | 30 ++ .../v1/internal/featurestore_tracing_stub.cc | 116 +++++ .../v1/internal/featurestore_tracing_stub.h | 40 ++ .../internal/gen_ai_tuning_auth_decorator.cc | 83 +++ .../internal/gen_ai_tuning_auth_decorator.h | 40 ++ .../internal/gen_ai_tuning_connection_impl.cc | 177 +++++++ .../internal/gen_ai_tuning_connection_impl.h | 30 ++ .../gen_ai_tuning_logging_decorator.cc | 116 +++++ .../gen_ai_tuning_logging_decorator.h | 40 ++ .../gen_ai_tuning_metadata_decorator.cc | 88 ++++ .../gen_ai_tuning_metadata_decorator.h | 40 ++ .../v1/internal/gen_ai_tuning_stub.cc | 117 +++++ .../v1/internal/gen_ai_tuning_stub.h | 102 +++- .../v1/internal/gen_ai_tuning_stub_factory.cc | 11 +- .../gen_ai_tuning_tracing_connection.cc | 92 ++++ .../gen_ai_tuning_tracing_connection.h | 30 ++ .../v1/internal/gen_ai_tuning_tracing_stub.cc | 116 +++++ .../v1/internal/gen_ai_tuning_tracing_stub.h | 40 ++ .../v1/internal/index_auth_decorator.cc | 83 +++ .../v1/internal/index_auth_decorator.h | 40 ++ .../v1/internal/index_connection_impl.cc | 175 +++++++ .../v1/internal/index_connection_impl.h | 30 ++ .../internal/index_endpoint_auth_decorator.cc | 85 +++ .../internal/index_endpoint_auth_decorator.h | 40 ++ .../index_endpoint_connection_impl.cc | 177 +++++++ .../internal/index_endpoint_connection_impl.h | 30 ++ .../index_endpoint_logging_decorator.cc | 116 +++++ .../index_endpoint_logging_decorator.h | 40 ++ .../index_endpoint_metadata_decorator.cc | 88 ++++ .../index_endpoint_metadata_decorator.h | 40 ++ .../v1/internal/index_endpoint_stub.cc | 117 +++++ .../v1/internal/index_endpoint_stub.h | 100 +++- .../internal/index_endpoint_stub_factory.cc | 11 +- .../index_endpoint_tracing_connection.cc | 92 ++++ .../index_endpoint_tracing_connection.h | 30 ++ .../internal/index_endpoint_tracing_stub.cc | 116 +++++ .../v1/internal/index_endpoint_tracing_stub.h | 40 ++ .../v1/internal/index_logging_decorator.cc | 113 ++++ .../v1/internal/index_logging_decorator.h | 40 ++ .../v1/internal/index_metadata_decorator.cc | 85 +++ .../v1/internal/index_metadata_decorator.h | 40 ++ .../aiplatform/v1/internal/index_stub.cc | 115 ++++ .../cloud/aiplatform/v1/internal/index_stub.h | 100 +++- .../v1/internal/index_stub_factory.cc | 11 +- .../v1/internal/index_tracing_connection.cc | 90 ++++ .../v1/internal/index_tracing_connection.h | 30 ++ .../v1/internal/index_tracing_stub.cc | 114 ++++ .../v1/internal/index_tracing_stub.h | 40 ++ .../v1/internal/job_auth_decorator.cc | 83 +++ .../v1/internal/job_auth_decorator.h | 40 ++ .../v1/internal/job_connection_impl.cc | 174 +++++++ .../v1/internal/job_connection_impl.h | 30 ++ .../v1/internal/job_logging_decorator.cc | 113 ++++ .../v1/internal/job_logging_decorator.h | 40 ++ .../v1/internal/job_metadata_decorator.cc | 85 +++ .../v1/internal/job_metadata_decorator.h | 40 ++ .../cloud/aiplatform/v1/internal/job_stub.cc | 114 ++++ .../cloud/aiplatform/v1/internal/job_stub.h | 100 +++- .../v1/internal/job_stub_factory.cc | 11 +- .../v1/internal/job_tracing_connection.cc | 90 ++++ .../v1/internal/job_tracing_connection.h | 30 ++ .../v1/internal/job_tracing_stub.cc | 113 ++++ .../aiplatform/v1/internal/job_tracing_stub.h | 40 ++ .../v1/internal/llm_utility_auth_decorator.cc | 83 +++ .../v1/internal/llm_utility_auth_decorator.h | 40 ++ .../internal/llm_utility_connection_impl.cc | 176 +++++++ .../v1/internal/llm_utility_connection_impl.h | 31 ++ .../internal/llm_utility_logging_decorator.cc | 115 ++++ .../internal/llm_utility_logging_decorator.h | 40 ++ .../llm_utility_metadata_decorator.cc | 88 ++++ .../internal/llm_utility_metadata_decorator.h | 40 ++ .../v1/internal/llm_utility_stub.cc | 117 +++++ .../aiplatform/v1/internal/llm_utility_stub.h | 102 +++- .../v1/internal/llm_utility_stub_factory.cc | 11 +- .../llm_utility_tracing_connection.cc | 93 ++++ .../internal/llm_utility_tracing_connection.h | 30 ++ .../v1/internal/llm_utility_tracing_stub.cc | 116 +++++ .../v1/internal/llm_utility_tracing_stub.h | 40 ++ .../v1/internal/match_auth_decorator.cc | 83 +++ .../v1/internal/match_auth_decorator.h | 40 ++ .../v1/internal/match_connection_impl.cc | 176 +++++++ .../v1/internal/match_connection_impl.h | 31 ++ .../v1/internal/match_logging_decorator.cc | 113 ++++ .../v1/internal/match_logging_decorator.h | 40 ++ .../v1/internal/match_metadata_decorator.cc | 85 +++ .../v1/internal/match_metadata_decorator.h | 40 ++ .../aiplatform/v1/internal/match_stub.cc | 115 ++++ .../cloud/aiplatform/v1/internal/match_stub.h | 102 +++- .../v1/internal/match_stub_factory.cc | 12 +- .../v1/internal/match_tracing_connection.cc | 91 ++++ .../v1/internal/match_tracing_connection.h | 30 ++ .../v1/internal/match_tracing_stub.cc | 114 ++++ .../v1/internal/match_tracing_stub.h | 40 ++ .../v1/internal/metadata_auth_decorator.cc | 83 +++ .../v1/internal/metadata_auth_decorator.h | 40 ++ .../v1/internal/metadata_connection_impl.cc | 175 +++++++ .../v1/internal/metadata_connection_impl.h | 30 ++ .../v1/internal/metadata_logging_decorator.cc | 113 ++++ .../v1/internal/metadata_logging_decorator.h | 40 ++ .../internal/metadata_metadata_decorator.cc | 86 +++ .../v1/internal/metadata_metadata_decorator.h | 40 ++ .../aiplatform/v1/internal/metadata_stub.cc | 117 +++++ .../aiplatform/v1/internal/metadata_stub.h | 100 +++- .../v1/internal/metadata_stub_factory.cc | 11 +- .../internal/metadata_tracing_connection.cc | 92 ++++ .../v1/internal/metadata_tracing_connection.h | 30 ++ .../v1/internal/metadata_tracing_stub.cc | 116 +++++ .../v1/internal/metadata_tracing_stub.h | 40 ++ .../v1/internal/migration_auth_decorator.cc | 83 +++ .../v1/internal/migration_auth_decorator.h | 40 ++ .../v1/internal/migration_connection_impl.cc | 175 +++++++ .../v1/internal/migration_connection_impl.h | 30 ++ .../internal/migration_logging_decorator.cc | 114 ++++ .../v1/internal/migration_logging_decorator.h | 40 ++ .../internal/migration_metadata_decorator.cc | 87 ++++ .../internal/migration_metadata_decorator.h | 40 ++ .../aiplatform/v1/internal/migration_stub.cc | 117 +++++ .../aiplatform/v1/internal/migration_stub.h | 100 +++- .../v1/internal/migration_stub_factory.cc | 11 +- .../internal/migration_tracing_connection.cc | 92 ++++ .../internal/migration_tracing_connection.h | 30 ++ .../v1/internal/migration_tracing_stub.cc | 116 +++++ .../v1/internal/migration_tracing_stub.h | 40 ++ .../v1/internal/model_auth_decorator.cc | 83 +++ .../v1/internal/model_auth_decorator.h | 40 ++ .../v1/internal/model_connection_impl.cc | 175 +++++++ .../v1/internal/model_connection_impl.h | 30 ++ .../internal/model_garden_auth_decorator.cc | 83 +++ .../v1/internal/model_garden_auth_decorator.h | 40 ++ .../internal/model_garden_connection_impl.cc | 178 +++++++ .../internal/model_garden_connection_impl.h | 31 ++ .../model_garden_logging_decorator.cc | 116 +++++ .../internal/model_garden_logging_decorator.h | 40 ++ .../model_garden_metadata_decorator.cc | 88 ++++ .../model_garden_metadata_decorator.h | 40 ++ .../v1/internal/model_garden_stub.cc | 117 +++++ .../v1/internal/model_garden_stub.h | 102 +++- .../v1/internal/model_garden_stub_factory.cc | 11 +- .../model_garden_tracing_connection.cc | 93 ++++ .../model_garden_tracing_connection.h | 30 ++ .../v1/internal/model_garden_tracing_stub.cc | 116 +++++ .../v1/internal/model_garden_tracing_stub.h | 40 ++ .../v1/internal/model_logging_decorator.cc | 113 ++++ .../v1/internal/model_logging_decorator.h | 40 ++ .../v1/internal/model_metadata_decorator.cc | 85 +++ .../v1/internal/model_metadata_decorator.h | 40 ++ .../aiplatform/v1/internal/model_stub.cc | 115 ++++ .../cloud/aiplatform/v1/internal/model_stub.h | 100 +++- .../v1/internal/model_stub_factory.cc | 11 +- .../v1/internal/model_tracing_connection.cc | 90 ++++ .../v1/internal/model_tracing_connection.h | 30 ++ .../v1/internal/model_tracing_stub.cc | 114 ++++ .../v1/internal/model_tracing_stub.h | 40 ++ .../v1/internal/notebook_auth_decorator.cc | 83 +++ .../v1/internal/notebook_auth_decorator.h | 40 ++ .../v1/internal/notebook_connection_impl.cc | 175 +++++++ .../v1/internal/notebook_connection_impl.h | 30 ++ .../v1/internal/notebook_logging_decorator.cc | 113 ++++ .../v1/internal/notebook_logging_decorator.h | 40 ++ .../internal/notebook_metadata_decorator.cc | 86 +++ .../v1/internal/notebook_metadata_decorator.h | 40 ++ .../aiplatform/v1/internal/notebook_stub.cc | 117 +++++ .../aiplatform/v1/internal/notebook_stub.h | 100 +++- .../v1/internal/notebook_stub_factory.cc | 11 +- .../internal/notebook_tracing_connection.cc | 92 ++++ .../v1/internal/notebook_tracing_connection.h | 30 ++ .../v1/internal/notebook_tracing_stub.cc | 116 +++++ .../v1/internal/notebook_tracing_stub.h | 40 ++ .../persistent_resource_auth_decorator.cc | 86 +++ .../persistent_resource_auth_decorator.h | 40 ++ .../persistent_resource_connection_impl.cc | 179 +++++++ .../persistent_resource_connection_impl.h | 30 ++ .../persistent_resource_logging_decorator.cc | 118 +++++ .../persistent_resource_logging_decorator.h | 40 ++ .../persistent_resource_metadata_decorator.cc | 90 ++++ .../persistent_resource_metadata_decorator.h | 40 ++ .../v1/internal/persistent_resource_stub.cc | 119 +++++ .../v1/internal/persistent_resource_stub.h | 100 +++- .../persistent_resource_stub_factory.cc | 11 +- .../persistent_resource_tracing_connection.cc | 92 ++++ .../persistent_resource_tracing_connection.h | 30 ++ .../persistent_resource_tracing_stub.cc | 121 +++++ .../persistent_resource_tracing_stub.h | 40 ++ .../v1/internal/pipeline_auth_decorator.cc | 83 +++ .../v1/internal/pipeline_auth_decorator.h | 40 ++ .../v1/internal/pipeline_connection_impl.cc | 175 +++++++ .../v1/internal/pipeline_connection_impl.h | 30 ++ .../v1/internal/pipeline_logging_decorator.cc | 113 ++++ .../v1/internal/pipeline_logging_decorator.h | 40 ++ .../internal/pipeline_metadata_decorator.cc | 86 +++ .../v1/internal/pipeline_metadata_decorator.h | 40 ++ .../aiplatform/v1/internal/pipeline_stub.cc | 117 +++++ .../aiplatform/v1/internal/pipeline_stub.h | 100 +++- .../v1/internal/pipeline_stub_factory.cc | 11 +- .../internal/pipeline_tracing_connection.cc | 92 ++++ .../v1/internal/pipeline_tracing_connection.h | 30 ++ .../v1/internal/pipeline_tracing_stub.cc | 116 +++++ .../v1/internal/pipeline_tracing_stub.h | 40 ++ .../v1/internal/prediction_auth_decorator.cc | 83 +++ .../v1/internal/prediction_auth_decorator.h | 40 ++ .../v1/internal/prediction_connection_impl.cc | 176 +++++++ .../v1/internal/prediction_connection_impl.h | 30 ++ .../internal/prediction_logging_decorator.cc | 115 ++++ .../internal/prediction_logging_decorator.h | 40 ++ .../internal/prediction_metadata_decorator.cc | 88 ++++ .../internal/prediction_metadata_decorator.h | 40 ++ .../aiplatform/v1/internal/prediction_stub.cc | 117 +++++ .../aiplatform/v1/internal/prediction_stub.h | 102 +++- .../v1/internal/prediction_stub_factory.cc | 11 +- .../internal/prediction_tracing_connection.cc | 92 ++++ .../internal/prediction_tracing_connection.h | 30 ++ .../v1/internal/prediction_tracing_stub.cc | 116 +++++ .../v1/internal/prediction_tracing_stub.h | 40 ++ .../v1/internal/schedule_auth_decorator.cc | 83 +++ .../v1/internal/schedule_auth_decorator.h | 40 ++ .../v1/internal/schedule_connection_impl.cc | 175 +++++++ .../v1/internal/schedule_connection_impl.h | 30 ++ .../v1/internal/schedule_logging_decorator.cc | 113 ++++ .../v1/internal/schedule_logging_decorator.h | 40 ++ .../internal/schedule_metadata_decorator.cc | 86 +++ .../v1/internal/schedule_metadata_decorator.h | 40 ++ .../aiplatform/v1/internal/schedule_stub.cc | 117 +++++ .../aiplatform/v1/internal/schedule_stub.h | 100 +++- .../v1/internal/schedule_stub_factory.cc | 11 +- .../internal/schedule_tracing_connection.cc | 92 ++++ .../v1/internal/schedule_tracing_connection.h | 30 ++ .../v1/internal/schedule_tracing_stub.cc | 116 +++++ .../v1/internal/schedule_tracing_stub.h | 40 ++ .../specialist_pool_auth_decorator.cc | 86 +++ .../internal/specialist_pool_auth_decorator.h | 40 ++ .../specialist_pool_connection_impl.cc | 177 +++++++ .../specialist_pool_connection_impl.h | 30 ++ .../specialist_pool_logging_decorator.cc | 116 +++++ .../specialist_pool_logging_decorator.h | 40 ++ .../specialist_pool_metadata_decorator.cc | 88 ++++ .../specialist_pool_metadata_decorator.h | 40 ++ .../v1/internal/specialist_pool_stub.cc | 119 +++++ .../v1/internal/specialist_pool_stub.h | 100 +++- .../internal/specialist_pool_stub_factory.cc | 11 +- .../specialist_pool_tracing_connection.cc | 92 ++++ .../specialist_pool_tracing_connection.h | 30 ++ .../internal/specialist_pool_tracing_stub.cc | 118 +++++ .../internal/specialist_pool_tracing_stub.h | 40 ++ .../v1/internal/tensorboard_auth_decorator.cc | 83 +++ .../v1/internal/tensorboard_auth_decorator.h | 40 ++ .../internal/tensorboard_connection_impl.cc | 177 +++++++ .../v1/internal/tensorboard_connection_impl.h | 30 ++ .../internal/tensorboard_logging_decorator.cc | 116 +++++ .../internal/tensorboard_logging_decorator.h | 40 ++ .../tensorboard_metadata_decorator.cc | 88 ++++ .../internal/tensorboard_metadata_decorator.h | 40 ++ .../v1/internal/tensorboard_stub.cc | 117 +++++ .../aiplatform/v1/internal/tensorboard_stub.h | 100 +++- .../v1/internal/tensorboard_stub_factory.cc | 11 +- .../tensorboard_tracing_connection.cc | 92 ++++ .../internal/tensorboard_tracing_connection.h | 30 ++ .../v1/internal/tensorboard_tracing_stub.cc | 116 +++++ .../v1/internal/tensorboard_tracing_stub.h | 40 ++ .../v1/internal/vizier_auth_decorator.cc | 83 +++ .../v1/internal/vizier_auth_decorator.h | 40 ++ .../v1/internal/vizier_connection_impl.cc | 175 +++++++ .../v1/internal/vizier_connection_impl.h | 30 ++ .../v1/internal/vizier_logging_decorator.cc | 113 ++++ .../v1/internal/vizier_logging_decorator.h | 40 ++ .../v1/internal/vizier_metadata_decorator.cc | 85 +++ .../v1/internal/vizier_metadata_decorator.h | 40 ++ .../aiplatform/v1/internal/vizier_stub.cc | 116 +++++ .../aiplatform/v1/internal/vizier_stub.h | 100 +++- .../v1/internal/vizier_stub_factory.cc | 11 +- .../v1/internal/vizier_tracing_connection.cc | 90 ++++ .../v1/internal/vizier_tracing_connection.h | 30 ++ .../v1/internal/vizier_tracing_stub.cc | 115 ++++ .../v1/internal/vizier_tracing_stub.h | 40 ++ google/cloud/aiplatform/v1/job_client.cc | 94 ++++ google/cloud/aiplatform/v1/job_client.h | 491 +++++++++++++++++ google/cloud/aiplatform/v1/job_connection.cc | 57 ++ google/cloud/aiplatform/v1/job_connection.h | 30 ++ .../v1/job_connection_idempotency_policy.cc | 51 ++ .../v1/job_connection_idempotency_policy.h | 33 ++ .../cloud/aiplatform/v1/llm_utility_client.cc | 99 ++++ .../cloud/aiplatform/v1/llm_utility_client.h | 492 ++++++++++++++++++ .../aiplatform/v1/llm_utility_connection.cc | 61 +++ .../aiplatform/v1/llm_utility_connection.h | 31 ++ ...m_utility_connection_idempotency_policy.cc | 51 ++ ...lm_utility_connection_idempotency_policy.h | 33 ++ google/cloud/aiplatform/v1/match_client.cc | 95 ++++ google/cloud/aiplatform/v1/match_client.h | 492 ++++++++++++++++++ .../cloud/aiplatform/v1/match_connection.cc | 58 +++ google/cloud/aiplatform/v1/match_connection.h | 31 ++ .../v1/match_connection_idempotency_policy.cc | 51 ++ .../v1/match_connection_idempotency_policy.h | 33 ++ google/cloud/aiplatform/v1/metadata_client.cc | 97 ++++ google/cloud/aiplatform/v1/metadata_client.h | 491 +++++++++++++++++ .../aiplatform/v1/metadata_connection.cc | 60 +++ .../cloud/aiplatform/v1/metadata_connection.h | 30 ++ .../metadata_connection_idempotency_policy.cc | 51 ++ .../metadata_connection_idempotency_policy.h | 33 ++ .../cloud/aiplatform/v1/migration_client.cc | 98 ++++ google/cloud/aiplatform/v1/migration_client.h | 492 ++++++++++++++++++ .../aiplatform/v1/migration_connection.cc | 60 +++ .../aiplatform/v1/migration_connection.h | 30 ++ ...migration_connection_idempotency_policy.cc | 51 ++ .../migration_connection_idempotency_policy.h | 33 ++ .../v1/mocks/mock_dataset_connection.h | 40 ++ ...mock_deployment_resource_pool_connection.h | 40 ++ .../v1/mocks/mock_endpoint_connection.h | 40 ++ ...ck_feature_online_store_admin_connection.h | 40 ++ .../mock_feature_online_store_connection.h | 40 ++ .../mocks/mock_feature_registry_connection.h | 40 ++ .../v1/mocks/mock_featurestore_connection.h | 40 ++ ...k_featurestore_online_serving_connection.h | 40 ++ .../v1/mocks/mock_gen_ai_tuning_connection.h | 40 ++ .../v1/mocks/mock_index_connection.h | 40 ++ .../v1/mocks/mock_index_endpoint_connection.h | 40 ++ .../aiplatform/v1/mocks/mock_job_connection.h | 40 ++ .../v1/mocks/mock_llm_utility_connection.h | 40 ++ .../v1/mocks/mock_match_connection.h | 40 ++ .../v1/mocks/mock_metadata_connection.h | 40 ++ .../v1/mocks/mock_migration_connection.h | 40 ++ .../v1/mocks/mock_model_connection.h | 40 ++ .../v1/mocks/mock_model_garden_connection.h | 40 ++ .../v1/mocks/mock_notebook_connection.h | 40 ++ .../mock_persistent_resource_connection.h | 40 ++ .../v1/mocks/mock_pipeline_connection.h | 40 ++ .../v1/mocks/mock_prediction_connection.h | 40 ++ .../v1/mocks/mock_schedule_connection.h | 40 ++ .../mocks/mock_specialist_pool_connection.h | 40 ++ .../v1/mocks/mock_tensorboard_connection.h | 40 ++ .../v1/mocks/mock_vizier_connection.h | 40 ++ google/cloud/aiplatform/v1/model_client.cc | 95 ++++ google/cloud/aiplatform/v1/model_client.h | 491 +++++++++++++++++ .../cloud/aiplatform/v1/model_connection.cc | 57 ++ google/cloud/aiplatform/v1/model_connection.h | 30 ++ .../v1/model_connection_idempotency_policy.cc | 51 ++ .../v1/model_connection_idempotency_policy.h | 33 ++ .../aiplatform/v1/model_garden_client.cc | 100 ++++ .../cloud/aiplatform/v1/model_garden_client.h | 492 ++++++++++++++++++ .../aiplatform/v1/model_garden_connection.cc | 61 +++ .../aiplatform/v1/model_garden_connection.h | 31 ++ ...el_garden_connection_idempotency_policy.cc | 51 ++ ...del_garden_connection_idempotency_policy.h | 33 ++ google/cloud/aiplatform/v1/notebook_client.cc | 97 ++++ google/cloud/aiplatform/v1/notebook_client.h | 491 +++++++++++++++++ .../aiplatform/v1/notebook_connection.cc | 60 +++ .../cloud/aiplatform/v1/notebook_connection.h | 30 ++ .../notebook_connection_idempotency_policy.cc | 51 ++ .../notebook_connection_idempotency_policy.h | 33 ++ .../v1/persistent_resource_client.cc | 102 ++++ .../v1/persistent_resource_client.h | 491 +++++++++++++++++ .../v1/persistent_resource_connection.cc | 62 +++ .../v1/persistent_resource_connection.h | 30 ++ ..._resource_connection_idempotency_policy.cc | 55 ++ ...t_resource_connection_idempotency_policy.h | 33 ++ google/cloud/aiplatform/v1/pipeline_client.cc | 97 ++++ google/cloud/aiplatform/v1/pipeline_client.h | 491 +++++++++++++++++ .../aiplatform/v1/pipeline_connection.cc | 60 +++ .../cloud/aiplatform/v1/pipeline_connection.h | 30 ++ .../pipeline_connection_idempotency_policy.cc | 51 ++ .../pipeline_connection_idempotency_policy.h | 33 ++ .../cloud/aiplatform/v1/prediction_client.cc | 99 ++++ .../cloud/aiplatform/v1/prediction_client.h | 492 ++++++++++++++++++ .../aiplatform/v1/prediction_connection.cc | 61 +++ .../aiplatform/v1/prediction_connection.h | 30 ++ ...rediction_connection_idempotency_policy.cc | 51 ++ ...prediction_connection_idempotency_policy.h | 33 ++ google/cloud/aiplatform/v1/schedule_client.cc | 97 ++++ google/cloud/aiplatform/v1/schedule_client.h | 492 ++++++++++++++++++ .../aiplatform/v1/schedule_connection.cc | 60 +++ .../cloud/aiplatform/v1/schedule_connection.h | 30 ++ .../schedule_connection_idempotency_policy.cc | 51 ++ .../schedule_connection_idempotency_policy.h | 33 ++ .../aiplatform/v1/specialist_pool_client.cc | 102 ++++ .../aiplatform/v1/specialist_pool_client.h | 492 ++++++++++++++++++ .../v1/specialist_pool_connection.cc | 60 +++ .../v1/specialist_pool_connection.h | 30 ++ ...list_pool_connection_idempotency_policy.cc | 52 ++ ...alist_pool_connection_idempotency_policy.h | 33 ++ .../cloud/aiplatform/v1/tensorboard_client.cc | 100 ++++ .../cloud/aiplatform/v1/tensorboard_client.h | 491 +++++++++++++++++ .../aiplatform/v1/tensorboard_connection.cc | 60 +++ .../aiplatform/v1/tensorboard_connection.h | 30 ++ ...nsorboard_connection_idempotency_policy.cc | 51 ++ ...ensorboard_connection_idempotency_policy.h | 33 ++ google/cloud/aiplatform/v1/vizier_client.cc | 95 ++++ google/cloud/aiplatform/v1/vizier_client.h | 491 +++++++++++++++++ .../cloud/aiplatform/v1/vizier_connection.cc | 58 +++ .../cloud/aiplatform/v1/vizier_connection.h | 30 ++ .../vizier_connection_idempotency_policy.cc | 51 ++ .../v1/vizier_connection_idempotency_policy.h | 33 ++ google/cloud/alloydb/BUILD.bazel | 2 + .../cloud/alloydb/v1/alloy_db_admin_client.cc | 70 +++ .../cloud/alloydb/v1/alloy_db_admin_client.h | 350 +++++++++++++ .../alloydb/v1/alloy_db_admin_connection.cc | 36 ++ .../alloydb/v1/alloy_db_admin_connection.h | 18 + ..._db_admin_connection_idempotency_policy.cc | 30 ++ ...y_db_admin_connection_idempotency_policy.h | 20 + .../internal/alloy_db_admin_auth_decorator.cc | 50 ++ .../internal/alloy_db_admin_auth_decorator.h | 24 + .../alloy_db_admin_connection_impl.cc | 121 +++++ .../internal/alloy_db_admin_connection_impl.h | 18 + .../alloy_db_admin_logging_decorator.cc | 68 +++ .../alloy_db_admin_logging_decorator.h | 24 + .../alloy_db_admin_metadata_decorator.cc | 50 ++ .../alloy_db_admin_metadata_decorator.h | 24 + .../v1/internal/alloy_db_admin_stub.cc | 69 +++ .../alloydb/v1/internal/alloy_db_admin_stub.h | 63 ++- .../internal/alloy_db_admin_stub_factory.cc | 9 +- .../alloy_db_admin_tracing_connection.cc | 56 ++ .../alloy_db_admin_tracing_connection.h | 18 + .../internal/alloy_db_admin_tracing_stub.cc | 69 +++ .../v1/internal/alloy_db_admin_tracing_stub.h | 24 + .../v1/mocks/mock_alloy_db_admin_connection.h | 23 + google/cloud/apikeys/v2/api_keys_client.cc | 14 + google/cloud/apikeys/v2/api_keys_client.h | 60 +++ .../cloud/apikeys/v2/api_keys_connection.cc | 5 + google/cloud/apikeys/v2/api_keys_connection.h | 3 + .../api_keys_connection_idempotency_policy.cc | 5 + .../api_keys_connection_idempotency_policy.h | 4 + .../v2/internal/api_keys_auth_decorator.cc | 8 + .../v2/internal/api_keys_auth_decorator.h | 4 + .../v2/internal/api_keys_connection_impl.cc | 13 + .../v2/internal/api_keys_connection_impl.h | 3 + .../v2/internal/api_keys_logging_decorator.cc | 11 + .../v2/internal/api_keys_logging_decorator.h | 4 + .../internal/api_keys_metadata_decorator.cc | 8 + .../v2/internal/api_keys_metadata_decorator.h | 4 + .../apikeys/v2/internal/api_keys_stub.cc | 11 + .../cloud/apikeys/v2/internal/api_keys_stub.h | 16 +- .../v2/internal/api_keys_stub_factory.cc | 5 +- .../internal/api_keys_tracing_connection.cc | 7 + .../v2/internal/api_keys_tracing_connection.h | 3 + .../v2/internal/api_keys_tracing_stub.cc | 11 + .../v2/internal/api_keys_tracing_stub.h | 4 + .../v2/mocks/mock_api_keys_connection.h | 4 + google/cloud/apphub/BUILD.bazel | 2 + google/cloud/apphub/v1/app_hub_client.cc | 86 +++ google/cloud/apphub/v1/app_hub_client.h | 453 ++++++++++++++++ google/cloud/apphub/v1/app_hub_connection.cc | 50 ++ google/cloud/apphub/v1/app_hub_connection.h | 27 + .../app_hub_connection_idempotency_policy.cc | 46 ++ .../app_hub_connection_idempotency_policy.h | 30 ++ .../v1/internal/app_hub_auth_decorator.cc | 75 +++ .../v1/internal/app_hub_auth_decorator.h | 36 ++ .../v1/internal/app_hub_connection_impl.cc | 159 ++++++ .../v1/internal/app_hub_connection_impl.h | 27 + .../v1/internal/app_hub_logging_decorator.cc | 102 ++++ .../v1/internal/app_hub_logging_decorator.h | 36 ++ .../v1/internal/app_hub_metadata_decorator.cc | 78 +++ .../v1/internal/app_hub_metadata_decorator.h | 36 ++ .../cloud/apphub/v1/internal/app_hub_stub.cc | 103 ++++ .../cloud/apphub/v1/internal/app_hub_stub.h | 92 +++- .../v1/internal/app_hub_stub_factory.cc | 11 +- .../v1/internal/app_hub_tracing_connection.cc | 74 +++ .../v1/internal/app_hub_tracing_connection.h | 27 + .../v1/internal/app_hub_tracing_stub.cc | 102 ++++ .../apphub/v1/internal/app_hub_tracing_stub.h | 36 ++ .../apphub/v1/mocks/mock_app_hub_connection.h | 36 ++ google/cloud/artifactregistry/BUILD.bazel | 2 + .../v1/artifact_registry_client.cc | 27 + .../v1/artifact_registry_client.h | 130 +++++ .../v1/artifact_registry_connection.cc | 20 + .../v1/artifact_registry_connection.h | 9 + ..._registry_connection_idempotency_policy.cc | 15 + ...t_registry_connection_idempotency_policy.h | 11 + .../artifact_registry_auth_decorator.cc | 25 + .../artifact_registry_auth_decorator.h | 12 + .../artifact_registry_connection_impl.cc | 63 +++ .../artifact_registry_connection_impl.h | 9 + .../artifact_registry_logging_decorator.cc | 35 ++ .../artifact_registry_logging_decorator.h | 12 + .../artifact_registry_metadata_decorator.cc | 26 + .../artifact_registry_metadata_decorator.h | 12 + .../v1/internal/artifact_registry_stub.cc | 36 ++ .../v1/internal/artifact_registry_stub.h | 39 +- .../artifact_registry_stub_factory.cc | 9 +- .../artifact_registry_tracing_connection.cc | 29 ++ .../artifact_registry_tracing_connection.h | 9 + .../artifact_registry_tracing_stub.cc | 36 ++ .../internal/artifact_registry_tracing_stub.h | 12 + .../mocks/mock_artifact_registry_connection.h | 12 + google/cloud/asset/v1/asset_client.cc | 14 + google/cloud/asset/v1/asset_client.h | 60 +++ google/cloud/asset/v1/asset_connection.cc | 5 + google/cloud/asset/v1/asset_connection.h | 3 + .../v1/asset_connection_idempotency_policy.cc | 5 + .../v1/asset_connection_idempotency_policy.h | 4 + .../asset/v1/internal/asset_auth_decorator.cc | 8 + .../asset/v1/internal/asset_auth_decorator.h | 4 + .../v1/internal/asset_connection_impl.cc | 14 + .../asset/v1/internal/asset_connection_impl.h | 3 + .../v1/internal/asset_logging_decorator.cc | 11 + .../v1/internal/asset_logging_decorator.h | 4 + .../v1/internal/asset_metadata_decorator.cc | 8 + .../v1/internal/asset_metadata_decorator.h | 4 + google/cloud/asset/v1/internal/asset_stub.cc | 11 + google/cloud/asset/v1/internal/asset_stub.h | 16 +- .../asset/v1/internal/asset_stub_factory.cc | 5 +- .../v1/internal/asset_tracing_connection.cc | 9 + .../v1/internal/asset_tracing_connection.h | 3 + .../asset/v1/internal/asset_tracing_stub.cc | 11 + .../asset/v1/internal/asset_tracing_stub.h | 4 + .../asset/v1/mocks/mock_asset_connection.h | 4 + .../v1/assured_workloads_client.cc | 34 ++ .../v1/assured_workloads_client.h | 152 ++++++ .../v1/assured_workloads_connection.cc | 14 + .../v1/assured_workloads_connection.h | 6 + ...workloads_connection_idempotency_policy.cc | 10 + ..._workloads_connection_idempotency_policy.h | 7 + .../assured_workloads_auth_decorator.cc | 18 + .../assured_workloads_auth_decorator.h | 8 + .../assured_workloads_connection_impl.cc | 48 ++ .../assured_workloads_connection_impl.h | 6 + .../assured_workloads_logging_decorator.cc | 24 + .../assured_workloads_logging_decorator.h | 8 + .../assured_workloads_metadata_decorator.cc | 18 + .../assured_workloads_metadata_decorator.h | 8 + .../v1/internal/assured_workloads_stub.cc | 24 + .../v1/internal/assured_workloads_stub.h | 24 +- .../assured_workloads_stub_factory.cc | 5 +- .../assured_workloads_tracing_connection.cc | 20 + .../assured_workloads_tracing_connection.h | 6 + .../assured_workloads_tracing_stub.cc | 26 + .../internal/assured_workloads_tracing_stub.h | 8 + .../mocks/mock_assured_workloads_connection.h | 7 + google/cloud/backupdr/BUILD.bazel | 2 + google/cloud/backupdr/v1/backup_dr_client.cc | 86 +++ google/cloud/backupdr/v1/backup_dr_client.h | 452 ++++++++++++++++ .../cloud/backupdr/v1/backup_dr_connection.cc | 51 ++ .../cloud/backupdr/v1/backup_dr_connection.h | 27 + ...backup_dr_connection_idempotency_policy.cc | 46 ++ .../backup_dr_connection_idempotency_policy.h | 30 ++ .../v1/internal/backup_dr_auth_decorator.cc | 75 +++ .../v1/internal/backup_dr_auth_decorator.h | 36 ++ .../v1/internal/backup_dr_connection_impl.cc | 159 ++++++ .../v1/internal/backup_dr_connection_impl.h | 27 + .../internal/backup_dr_logging_decorator.cc | 102 ++++ .../v1/internal/backup_dr_logging_decorator.h | 36 ++ .../internal/backup_dr_metadata_decorator.cc | 78 +++ .../internal/backup_dr_metadata_decorator.h | 36 ++ .../backupdr/v1/internal/backup_dr_stub.cc | 103 ++++ .../backupdr/v1/internal/backup_dr_stub.h | 92 +++- .../v1/internal/backup_dr_stub_factory.cc | 11 +- .../internal/backup_dr_tracing_connection.cc | 81 +++ .../internal/backup_dr_tracing_connection.h | 27 + .../v1/internal/backup_dr_tracing_stub.cc | 102 ++++ .../v1/internal/backup_dr_tracing_stub.h | 36 ++ .../v1/mocks/mock_backup_dr_connection.h | 36 ++ 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 | 6 + ..._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 | 26 +- .../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 | 70 +++ google/cloud/batch/v1/batch_client.h | 350 +++++++++++++ google/cloud/batch/v1/batch_connection.cc | 36 ++ google/cloud/batch/v1/batch_connection.h | 18 + .../v1/batch_connection_idempotency_policy.cc | 30 ++ .../v1/batch_connection_idempotency_policy.h | 20 + .../batch/v1/internal/batch_auth_decorator.cc | 50 ++ .../batch/v1/internal/batch_auth_decorator.h | 24 + .../v1/internal/batch_connection_impl.cc | 121 +++++ .../batch/v1/internal/batch_connection_impl.h | 18 + .../v1/internal/batch_logging_decorator.cc | 68 +++ .../v1/internal/batch_logging_decorator.h | 24 + .../v1/internal/batch_metadata_decorator.cc | 50 ++ .../v1/internal/batch_metadata_decorator.h | 24 + google/cloud/batch/v1/internal/batch_stub.cc | 69 +++ google/cloud/batch/v1/internal/batch_stub.h | 63 ++- .../batch/v1/internal/batch_stub_factory.cc | 9 +- .../v1/internal/batch_tracing_connection.cc | 56 ++ .../v1/internal/batch_tracing_connection.h | 18 + .../batch/v1/internal/batch_tracing_stub.cc | 69 +++ .../batch/v1/internal/batch_tracing_stub.h | 24 + .../batch/v1/mocks/mock_batch_connection.h | 23 + google/cloud/beyondcorp/BUILD.bazel | 2 + .../v1/app_connections_client.cc | 95 ++++ .../v1/app_connections_client.h | 452 ++++++++++++++++ .../v1/app_connections_connection.cc | 54 ++ .../v1/app_connections_connection.h | 27 + ...nnections_connection_idempotency_policy.cc | 47 ++ ...onnections_connection_idempotency_policy.h | 30 ++ .../app_connections_auth_decorator.cc | 77 +++ .../internal/app_connections_auth_decorator.h | 36 ++ .../app_connections_connection_impl.cc | 165 ++++++ .../app_connections_connection_impl.h | 27 + .../app_connections_logging_decorator.cc | 104 ++++ .../app_connections_logging_decorator.h | 36 ++ .../app_connections_metadata_decorator.cc | 80 +++ .../app_connections_metadata_decorator.h | 36 ++ .../v1/internal/app_connections_stub.cc | 107 ++++ .../v1/internal/app_connections_stub.h | 92 +++- .../internal/app_connections_stub_factory.cc | 11 +- .../app_connections_tracing_connection.cc | 92 ++++ .../app_connections_tracing_connection.h | 27 + .../internal/app_connections_tracing_stub.cc | 115 ++++ .../internal/app_connections_tracing_stub.h | 36 ++ .../mocks/mock_app_connections_connection.h | 36 ++ .../appconnectors/v1/app_connectors_client.cc | 95 ++++ .../appconnectors/v1/app_connectors_client.h | 452 ++++++++++++++++ .../v1/app_connectors_connection.cc | 54 ++ .../v1/app_connectors_connection.h | 27 + ...onnectors_connection_idempotency_policy.cc | 46 ++ ...connectors_connection_idempotency_policy.h | 30 ++ .../internal/app_connectors_auth_decorator.cc | 76 +++ .../internal/app_connectors_auth_decorator.h | 36 ++ .../app_connectors_connection_impl.cc | 165 ++++++ .../internal/app_connectors_connection_impl.h | 27 + .../app_connectors_logging_decorator.cc | 104 ++++ .../app_connectors_logging_decorator.h | 36 ++ .../app_connectors_metadata_decorator.cc | 80 +++ .../app_connectors_metadata_decorator.h | 36 ++ .../v1/internal/app_connectors_stub.cc | 105 ++++ .../v1/internal/app_connectors_stub.h | 92 +++- .../internal/app_connectors_stub_factory.cc | 11 +- .../app_connectors_tracing_connection.cc | 92 ++++ .../app_connectors_tracing_connection.h | 27 + .../internal/app_connectors_tracing_stub.cc | 113 ++++ .../v1/internal/app_connectors_tracing_stub.h | 36 ++ .../v1/mocks/mock_app_connectors_connection.h | 36 ++ .../appgateways/v1/app_gateways_client.cc | 93 ++++ .../appgateways/v1/app_gateways_client.h | 452 ++++++++++++++++ .../appgateways/v1/app_gateways_connection.cc | 54 ++ .../appgateways/v1/app_gateways_connection.h | 27 + ..._gateways_connection_idempotency_policy.cc | 46 ++ ...p_gateways_connection_idempotency_policy.h | 30 ++ .../internal/app_gateways_auth_decorator.cc | 75 +++ .../v1/internal/app_gateways_auth_decorator.h | 36 ++ .../internal/app_gateways_connection_impl.cc | 165 ++++++ .../internal/app_gateways_connection_impl.h | 27 + .../app_gateways_logging_decorator.cc | 104 ++++ .../internal/app_gateways_logging_decorator.h | 36 ++ .../app_gateways_metadata_decorator.cc | 80 +++ .../app_gateways_metadata_decorator.h | 36 ++ .../v1/internal/app_gateways_stub.cc | 105 ++++ .../v1/internal/app_gateways_stub.h | 92 +++- .../v1/internal/app_gateways_stub_factory.cc | 11 +- .../app_gateways_tracing_connection.cc | 87 ++++ .../app_gateways_tracing_connection.h | 27 + .../v1/internal/app_gateways_tracing_stub.cc | 113 ++++ .../v1/internal/app_gateways_tracing_stub.h | 36 ++ .../v1/mocks/mock_app_gateways_connection.h | 36 ++ 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 | 6 + ..._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 | 27 +- .../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 | 74 +++ .../v1/certificate_manager_client.h | 350 +++++++++++++ .../v1/certificate_manager_connection.cc | 38 ++ .../v1/certificate_manager_connection.h | 18 + ...e_manager_connection_idempotency_policy.cc | 30 ++ ...te_manager_connection_idempotency_policy.h | 20 + .../certificate_manager_auth_decorator.cc | 50 ++ .../certificate_manager_auth_decorator.h | 24 + .../certificate_manager_connection_impl.cc | 123 +++++ .../certificate_manager_connection_impl.h | 18 + .../certificate_manager_logging_decorator.cc | 70 +++ .../certificate_manager_logging_decorator.h | 24 + .../certificate_manager_metadata_decorator.cc | 52 ++ .../certificate_manager_metadata_decorator.h | 24 + .../v1/internal/certificate_manager_stub.cc | 70 +++ .../v1/internal/certificate_manager_stub.h | 63 ++- .../certificate_manager_stub_factory.cc | 9 +- .../certificate_manager_tracing_connection.cc | 56 ++ .../certificate_manager_tracing_connection.h | 18 + .../certificate_manager_tracing_stub.cc | 73 +++ .../certificate_manager_tracing_stub.h | 24 + .../mock_certificate_manager_connection.h | 23 + .../cloud/channel/v1/cloud_channel_client.cc | 61 +++ .../cloud/channel/v1/cloud_channel_client.h | 280 ++++++++++ .../channel/v1/cloud_channel_connection.cc | 24 + .../channel/v1/cloud_channel_connection.h | 12 + ...d_channel_connection_idempotency_policy.cc | 20 + ...ud_channel_connection_idempotency_policy.h | 13 + .../v1/cloud_channel_reports_client.cc | 62 +++ .../channel/v1/cloud_channel_reports_client.h | 280 ++++++++++ .../v1/cloud_channel_reports_connection.cc | 24 + .../v1/cloud_channel_reports_connection.h | 12 + ...l_reports_connection_idempotency_policy.cc | 23 + ...el_reports_connection_idempotency_policy.h | 13 + .../internal/cloud_channel_auth_decorator.cc | 33 ++ .../internal/cloud_channel_auth_decorator.h | 16 + .../internal/cloud_channel_connection_impl.cc | 73 +++ .../internal/cloud_channel_connection_impl.h | 12 + .../cloud_channel_logging_decorator.cc | 46 ++ .../cloud_channel_logging_decorator.h | 16 + .../cloud_channel_metadata_decorator.cc | 34 ++ .../cloud_channel_metadata_decorator.h | 16 + .../cloud_channel_reports_auth_decorator.cc | 34 ++ .../cloud_channel_reports_auth_decorator.h | 16 + .../cloud_channel_reports_connection_impl.cc | 74 +++ .../cloud_channel_reports_connection_impl.h | 12 + ...cloud_channel_reports_logging_decorator.cc | 46 ++ .../cloud_channel_reports_logging_decorator.h | 16 + ...loud_channel_reports_metadata_decorator.cc | 34 ++ ...cloud_channel_reports_metadata_decorator.h | 16 + .../v1/internal/cloud_channel_reports_stub.cc | 46 ++ .../v1/internal/cloud_channel_reports_stub.h | 40 +- .../cloud_channel_reports_stub_factory.cc | 5 +- ...loud_channel_reports_tracing_connection.cc | 36 ++ ...cloud_channel_reports_tracing_connection.h | 12 + .../cloud_channel_reports_tracing_stub.cc | 46 ++ .../cloud_channel_reports_tracing_stub.h | 16 + .../channel/v1/internal/cloud_channel_stub.cc | 46 ++ .../channel/v1/internal/cloud_channel_stub.h | 40 +- .../v1/internal/cloud_channel_stub_factory.cc | 5 +- .../cloud_channel_tracing_connection.cc | 36 ++ .../cloud_channel_tracing_connection.h | 12 + .../v1/internal/cloud_channel_tracing_stub.cc | 46 ++ .../v1/internal/cloud_channel_tracing_stub.h | 16 + .../v1/mocks/mock_cloud_channel_connection.h | 15 + .../mock_cloud_channel_reports_connection.h | 15 + google/cloud/cloudbuild/BUILD.bazel | 2 + .../repository_manager_auth_decorator.cc | 41 ++ .../repository_manager_auth_decorator.h | 20 + .../repository_manager_connection_impl.cc | 67 +++ .../repository_manager_connection_impl.h | 15 + .../repository_manager_logging_decorator.cc | 56 ++ .../repository_manager_logging_decorator.h | 20 + .../repository_manager_metadata_decorator.cc | 45 ++ .../repository_manager_metadata_decorator.h | 20 + .../v2/internal/repository_manager_stub.cc | 58 +++ .../v2/internal/repository_manager_stub.h | 53 +- .../repository_manager_stub_factory.cc | 8 +- .../repository_manager_tracing_connection.cc | 44 ++ .../repository_manager_tracing_connection.h | 15 + .../repository_manager_tracing_stub.cc | 57 ++ .../repository_manager_tracing_stub.h | 20 + .../mock_repository_manager_connection.h | 21 + .../v2/repository_manager_client.cc | 47 ++ .../cloudbuild/v2/repository_manager_client.h | 235 +++++++++ .../v2/repository_manager_connection.cc | 27 + .../v2/repository_manager_connection.h | 15 + ...y_manager_connection_idempotency_policy.cc | 26 + ...ry_manager_connection_idempotency_policy.h | 17 + .../v1/consumer_procurement_client.cc | 16 + .../v1/consumer_procurement_client.h | 60 +++ .../v1/consumer_procurement_connection.cc | 6 + .../v1/consumer_procurement_connection.h | 3 + ...ocurement_connection_idempotency_policy.cc | 5 + ...rocurement_connection_idempotency_policy.h | 4 + .../consumer_procurement_auth_decorator.cc | 9 + .../consumer_procurement_auth_decorator.h | 4 + .../consumer_procurement_connection_impl.cc | 14 + .../consumer_procurement_connection_impl.h | 3 + .../consumer_procurement_logging_decorator.cc | 12 + .../consumer_procurement_logging_decorator.h | 4 + ...consumer_procurement_metadata_decorator.cc | 9 + .../consumer_procurement_metadata_decorator.h | 4 + .../v1/internal/consumer_procurement_stub.cc | 12 + .../v1/internal/consumer_procurement_stub.h | 16 +- .../consumer_procurement_stub_factory.cc | 5 +- ...consumer_procurement_tracing_connection.cc | 10 + .../consumer_procurement_tracing_connection.h | 3 + .../consumer_procurement_tracing_stub.cc | 14 + .../consumer_procurement_tracing_stub.h | 4 + .../mock_consumer_procurement_connection.h | 4 + .../cloud/composer/v1/environments_client.cc | 43 ++ .../cloud/composer/v1/environments_client.h | 207 ++++++++ .../composer/v1/environments_connection.cc | 18 + .../composer/v1/environments_connection.h | 9 + ...ironments_connection_idempotency_policy.cc | 15 + ...vironments_connection_idempotency_policy.h | 10 + .../composer/v1/image_versions_client.cc | 43 ++ .../cloud/composer/v1/image_versions_client.h | 207 ++++++++ .../composer/v1/image_versions_connection.cc | 18 + .../composer/v1/image_versions_connection.h | 9 + ..._versions_connection_idempotency_policy.cc | 15 + ...e_versions_connection_idempotency_policy.h | 10 + .../internal/environments_auth_decorator.cc | 25 + .../v1/internal/environments_auth_decorator.h | 12 + .../internal/environments_connection_impl.cc | 60 +++ .../internal/environments_connection_impl.h | 9 + .../environments_logging_decorator.cc | 34 ++ .../internal/environments_logging_decorator.h | 12 + .../environments_metadata_decorator.cc | 25 + .../environments_metadata_decorator.h | 12 + .../composer/v1/internal/environments_stub.cc | 34 ++ .../composer/v1/internal/environments_stub.h | 32 +- .../v1/internal/environments_stub_factory.cc | 5 +- .../environments_tracing_connection.cc | 28 + .../environments_tracing_connection.h | 9 + .../v1/internal/environments_tracing_stub.cc | 37 ++ .../v1/internal/environments_tracing_stub.h | 12 + .../internal/image_versions_auth_decorator.cc | 25 + .../internal/image_versions_auth_decorator.h | 12 + .../image_versions_connection_impl.cc | 60 +++ .../internal/image_versions_connection_impl.h | 9 + .../image_versions_logging_decorator.cc | 34 ++ .../image_versions_logging_decorator.h | 12 + .../image_versions_metadata_decorator.cc | 25 + .../image_versions_metadata_decorator.h | 12 + .../v1/internal/image_versions_stub.cc | 34 ++ .../v1/internal/image_versions_stub.h | 34 +- .../internal/image_versions_stub_factory.cc | 6 +- .../image_versions_tracing_connection.cc | 28 + .../image_versions_tracing_connection.h | 9 + .../internal/image_versions_tracing_stub.cc | 37 ++ .../v1/internal/image_versions_tracing_stub.h | 12 + .../v1/mocks/mock_environments_connection.h | 11 + .../v1/mocks/mock_image_versions_connection.h | 11 + .../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 | 7 + ...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 | 27 +- .../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 | 86 +++ google/cloud/config/v1/config_client.h | 452 ++++++++++++++++ google/cloud/config/v1/config_connection.cc | 50 ++ google/cloud/config/v1/config_connection.h | 27 + .../config_connection_idempotency_policy.cc | 46 ++ .../v1/config_connection_idempotency_policy.h | 30 ++ .../v1/internal/config_auth_decorator.cc | 75 +++ .../v1/internal/config_auth_decorator.h | 36 ++ .../v1/internal/config_connection_impl.cc | 159 ++++++ .../v1/internal/config_connection_impl.h | 27 + .../v1/internal/config_logging_decorator.cc | 102 ++++ .../v1/internal/config_logging_decorator.h | 36 ++ .../v1/internal/config_metadata_decorator.cc | 78 +++ .../v1/internal/config_metadata_decorator.h | 36 ++ .../cloud/config/v1/internal/config_stub.cc | 103 ++++ google/cloud/config/v1/internal/config_stub.h | 92 +++- .../config/v1/internal/config_stub_factory.cc | 11 +- .../v1/internal/config_tracing_connection.cc | 74 +++ .../v1/internal/config_tracing_connection.h | 27 + .../config/v1/internal/config_tracing_stub.cc | 102 ++++ .../config/v1/internal/config_tracing_stub.h | 36 ++ .../config/v1/mocks/mock_config_connection.h | 36 ++ google/cloud/connectors/BUILD.bazel | 2 + .../cloud/connectors/v1/connectors_client.cc | 88 ++++ .../cloud/connectors/v1/connectors_client.h | 452 ++++++++++++++++ .../connectors/v1/connectors_connection.cc | 52 ++ .../connectors/v1/connectors_connection.h | 27 + ...onnectors_connection_idempotency_policy.cc | 46 ++ ...connectors_connection_idempotency_policy.h | 30 ++ .../v1/internal/connectors_auth_decorator.cc | 75 +++ .../v1/internal/connectors_auth_decorator.h | 36 ++ .../v1/internal/connectors_connection_impl.cc | 160 ++++++ .../v1/internal/connectors_connection_impl.h | 27 + .../internal/connectors_logging_decorator.cc | 102 ++++ .../internal/connectors_logging_decorator.h | 36 ++ .../internal/connectors_metadata_decorator.cc | 78 +++ .../internal/connectors_metadata_decorator.h | 36 ++ .../connectors/v1/internal/connectors_stub.cc | 103 ++++ .../connectors/v1/internal/connectors_stub.h | 92 +++- .../v1/internal/connectors_stub_factory.cc | 11 +- .../internal/connectors_tracing_connection.cc | 81 +++ .../internal/connectors_tracing_connection.h | 27 + .../v1/internal/connectors_tracing_stub.cc | 102 ++++ .../v1/internal/connectors_tracing_stub.h | 36 ++ .../v1/mocks/mock_connectors_connection.h | 36 ++ .../v1/contact_center_insights_client.cc | 48 ++ .../v1/contact_center_insights_client.h | 225 ++++++++ .../v1/contact_center_insights_connection.cc | 19 + .../v1/contact_center_insights_connection.h | 9 + ..._insights_connection_idempotency_policy.cc | 15 + ...r_insights_connection_idempotency_policy.h | 10 + .../contact_center_insights_auth_decorator.cc | 26 + .../contact_center_insights_auth_decorator.h | 12 + ...contact_center_insights_connection_impl.cc | 61 +++ .../contact_center_insights_connection_impl.h | 9 + ...ntact_center_insights_logging_decorator.cc | 35 ++ ...ontact_center_insights_logging_decorator.h | 12 + ...tact_center_insights_metadata_decorator.cc | 26 + ...ntact_center_insights_metadata_decorator.h | 12 + .../internal/contact_center_insights_stub.cc | 35 ++ .../internal/contact_center_insights_stub.h | 32 +- .../contact_center_insights_stub_factory.cc | 5 +- ...tact_center_insights_tracing_connection.cc | 31 ++ ...ntact_center_insights_tracing_connection.h | 9 + .../contact_center_insights_tracing_stub.cc | 38 ++ .../contact_center_insights_tracing_stub.h | 12 + .../mock_contact_center_insights_connection.h | 11 + .../contentwarehouse/v1/document_client.cc | 14 + .../contentwarehouse/v1/document_client.h | 60 +++ .../v1/document_connection.cc | 6 + .../contentwarehouse/v1/document_connection.h | 3 + .../document_connection_idempotency_policy.cc | 5 + .../document_connection_idempotency_policy.h | 4 + .../v1/document_link_client.cc | 15 + .../v1/document_link_client.h | 60 +++ .../v1/document_link_connection.cc | 6 + .../v1/document_link_connection.h | 3 + ...ment_link_connection_idempotency_policy.cc | 5 + ...ument_link_connection_idempotency_policy.h | 4 + .../v1/document_schema_client.cc | 16 + .../v1/document_schema_client.h | 60 +++ .../v1/document_schema_connection.cc | 6 + .../v1/document_schema_connection.h | 3 + ...nt_schema_connection_idempotency_policy.cc | 5 + ...ent_schema_connection_idempotency_policy.h | 4 + .../v1/internal/document_auth_decorator.cc | 8 + .../v1/internal/document_auth_decorator.h | 4 + .../v1/internal/document_connection_impl.cc | 14 + .../v1/internal/document_connection_impl.h | 3 + .../internal/document_link_auth_decorator.cc | 8 + .../internal/document_link_auth_decorator.h | 4 + .../internal/document_link_connection_impl.cc | 14 + .../internal/document_link_connection_impl.h | 3 + .../document_link_logging_decorator.cc | 12 + .../document_link_logging_decorator.h | 4 + .../document_link_metadata_decorator.cc | 9 + .../document_link_metadata_decorator.h | 4 + .../v1/internal/document_link_stub.cc | 12 + .../v1/internal/document_link_stub.h | 18 +- .../v1/internal/document_link_stub_factory.cc | 5 +- .../document_link_tracing_connection.cc | 9 + .../document_link_tracing_connection.h | 3 + .../v1/internal/document_link_tracing_stub.cc | 12 + .../v1/internal/document_link_tracing_stub.h | 4 + .../v1/internal/document_logging_decorator.cc | 11 + .../v1/internal/document_logging_decorator.h | 4 + .../internal/document_metadata_decorator.cc | 8 + .../v1/internal/document_metadata_decorator.h | 4 + .../document_schema_auth_decorator.cc | 9 + .../internal/document_schema_auth_decorator.h | 4 + .../document_schema_connection_impl.cc | 14 + .../document_schema_connection_impl.h | 3 + .../document_schema_logging_decorator.cc | 12 + .../document_schema_logging_decorator.h | 4 + .../document_schema_metadata_decorator.cc | 9 + .../document_schema_metadata_decorator.h | 4 + .../v1/internal/document_schema_stub.cc | 12 + .../v1/internal/document_schema_stub.h | 18 +- .../internal/document_schema_stub_factory.cc | 5 +- .../document_schema_tracing_connection.cc | 9 + .../document_schema_tracing_connection.h | 3 + .../internal/document_schema_tracing_stub.cc | 12 + .../internal/document_schema_tracing_stub.h | 4 + .../v1/internal/document_stub.cc | 12 + .../v1/internal/document_stub.h | 18 +- .../v1/internal/document_stub_factory.cc | 5 +- .../internal/document_tracing_connection.cc | 9 + .../v1/internal/document_tracing_connection.h | 3 + .../v1/internal/document_tracing_stub.cc | 12 + .../v1/internal/document_tracing_stub.h | 4 + .../v1/internal/pipeline_auth_decorator.cc | 8 + .../v1/internal/pipeline_auth_decorator.h | 4 + .../v1/internal/pipeline_connection_impl.cc | 14 + .../v1/internal/pipeline_connection_impl.h | 3 + .../v1/internal/pipeline_logging_decorator.cc | 11 + .../v1/internal/pipeline_logging_decorator.h | 4 + .../internal/pipeline_metadata_decorator.cc | 8 + .../v1/internal/pipeline_metadata_decorator.h | 4 + .../v1/internal/pipeline_stub.cc | 12 + .../v1/internal/pipeline_stub.h | 16 +- .../v1/internal/pipeline_stub_factory.cc | 5 +- .../internal/pipeline_tracing_connection.cc | 9 + .../v1/internal/pipeline_tracing_connection.h | 3 + .../v1/internal/pipeline_tracing_stub.cc | 12 + .../v1/internal/pipeline_tracing_stub.h | 4 + .../v1/internal/rule_set_auth_decorator.cc | 8 + .../v1/internal/rule_set_auth_decorator.h | 4 + .../v1/internal/rule_set_connection_impl.cc | 14 + .../v1/internal/rule_set_connection_impl.h | 3 + .../v1/internal/rule_set_logging_decorator.cc | 11 + .../v1/internal/rule_set_logging_decorator.h | 4 + .../internal/rule_set_metadata_decorator.cc | 8 + .../v1/internal/rule_set_metadata_decorator.h | 4 + .../v1/internal/rule_set_stub.cc | 12 + .../v1/internal/rule_set_stub.h | 18 +- .../v1/internal/rule_set_stub_factory.cc | 6 +- .../internal/rule_set_tracing_connection.cc | 9 + .../v1/internal/rule_set_tracing_connection.h | 3 + .../v1/internal/rule_set_tracing_stub.cc | 12 + .../v1/internal/rule_set_tracing_stub.h | 4 + .../v1/internal/synonym_set_auth_decorator.cc | 8 + .../v1/internal/synonym_set_auth_decorator.h | 4 + .../internal/synonym_set_connection_impl.cc | 14 + .../v1/internal/synonym_set_connection_impl.h | 3 + .../internal/synonym_set_logging_decorator.cc | 11 + .../internal/synonym_set_logging_decorator.h | 4 + .../synonym_set_metadata_decorator.cc | 9 + .../internal/synonym_set_metadata_decorator.h | 4 + .../v1/internal/synonym_set_stub.cc | 12 + .../v1/internal/synonym_set_stub.h | 18 +- .../v1/internal/synonym_set_stub_factory.cc | 5 +- .../synonym_set_tracing_connection.cc | 9 + .../internal/synonym_set_tracing_connection.h | 3 + .../v1/internal/synonym_set_tracing_stub.cc | 12 + .../v1/internal/synonym_set_tracing_stub.h | 4 + .../v1/mocks/mock_document_connection.h | 4 + .../v1/mocks/mock_document_link_connection.h | 4 + .../mocks/mock_document_schema_connection.h | 4 + .../v1/mocks/mock_pipeline_connection.h | 4 + .../v1/mocks/mock_rule_set_connection.h | 4 + .../v1/mocks/mock_synonym_set_connection.h | 4 + .../contentwarehouse/v1/pipeline_client.cc | 14 + .../contentwarehouse/v1/pipeline_client.h | 60 +++ .../v1/pipeline_connection.cc | 6 + .../contentwarehouse/v1/pipeline_connection.h | 3 + .../pipeline_connection_idempotency_policy.cc | 5 + .../pipeline_connection_idempotency_policy.h | 4 + .../contentwarehouse/v1/rule_set_client.cc | 14 + .../contentwarehouse/v1/rule_set_client.h | 60 +++ .../v1/rule_set_connection.cc | 5 + .../contentwarehouse/v1/rule_set_connection.h | 3 + .../rule_set_connection_idempotency_policy.cc | 5 + .../rule_set_connection_idempotency_policy.h | 4 + .../contentwarehouse/v1/synonym_set_client.cc | 14 + .../contentwarehouse/v1/synonym_set_client.h | 60 +++ .../v1/synonym_set_connection.cc | 6 + .../v1/synonym_set_connection.h | 3 + ...nonym_set_connection_idempotency_policy.cc | 5 + ...ynonym_set_connection_idempotency_policy.h | 4 + google/cloud/datacatalog/BUILD.bazel | 2 + .../v1/internal/lineage_auth_decorator.cc | 33 ++ .../v1/internal/lineage_auth_decorator.h | 16 + .../v1/internal/lineage_connection_impl.cc | 72 +++ .../v1/internal/lineage_connection_impl.h | 12 + .../v1/internal/lineage_logging_decorator.cc | 45 ++ .../v1/internal/lineage_logging_decorator.h | 16 + .../v1/internal/lineage_metadata_decorator.cc | 33 ++ .../v1/internal/lineage_metadata_decorator.h | 16 + .../lineage/v1/internal/lineage_stub.cc | 45 ++ .../lineage/v1/internal/lineage_stub.h | 40 +- .../v1/internal/lineage_stub_factory.cc | 5 +- .../v1/internal/lineage_tracing_connection.cc | 35 ++ .../v1/internal/lineage_tracing_connection.h | 12 + .../v1/internal/lineage_tracing_stub.cc | 45 ++ .../v1/internal/lineage_tracing_stub.h | 16 + .../datacatalog/lineage/v1/lineage_client.cc | 55 ++ .../datacatalog/lineage/v1/lineage_client.h | 280 ++++++++++ .../lineage/v1/lineage_connection.cc | 22 + .../lineage/v1/lineage_connection.h | 12 + .../lineage_connection_idempotency_policy.cc | 20 + .../lineage_connection_idempotency_policy.h | 13 + .../v1/mocks/mock_lineage_connection.h | 15 + .../datacatalog/v1/data_catalog_client.cc | 57 ++ .../datacatalog/v1/data_catalog_client.h | 280 ++++++++++ .../datacatalog/v1/data_catalog_connection.cc | 23 + .../datacatalog/v1/data_catalog_connection.h | 12 + ...a_catalog_connection_idempotency_policy.cc | 20 + ...ta_catalog_connection_idempotency_policy.h | 13 + .../internal/data_catalog_auth_decorator.cc | 33 ++ .../v1/internal/data_catalog_auth_decorator.h | 16 + .../internal/data_catalog_connection_impl.cc | 73 +++ .../internal/data_catalog_connection_impl.h | 12 + .../data_catalog_logging_decorator.cc | 45 ++ .../internal/data_catalog_logging_decorator.h | 16 + .../data_catalog_metadata_decorator.cc | 33 ++ .../data_catalog_metadata_decorator.h | 16 + .../v1/internal/data_catalog_stub.cc | 45 ++ .../v1/internal/data_catalog_stub.h | 40 +- .../v1/internal/data_catalog_stub_factory.cc | 5 +- .../data_catalog_tracing_connection.cc | 36 ++ .../data_catalog_tracing_connection.h | 12 + .../v1/internal/data_catalog_tracing_stub.cc | 45 ++ .../v1/internal/data_catalog_tracing_stub.h | 16 + .../policy_tag_manager_auth_decorator.cc | 33 ++ .../policy_tag_manager_auth_decorator.h | 16 + .../policy_tag_manager_connection_impl.cc | 73 +++ .../policy_tag_manager_connection_impl.h | 12 + .../policy_tag_manager_logging_decorator.cc | 45 ++ .../policy_tag_manager_logging_decorator.h | 16 + .../policy_tag_manager_metadata_decorator.cc | 33 ++ .../policy_tag_manager_metadata_decorator.h | 16 + ...ag_manager_serialization_auth_decorator.cc | 34 ++ ...tag_manager_serialization_auth_decorator.h | 16 + ...g_manager_serialization_connection_impl.cc | 75 +++ ...ag_manager_serialization_connection_impl.h | 13 + ...manager_serialization_logging_decorator.cc | 46 ++ ..._manager_serialization_logging_decorator.h | 16 + ...anager_serialization_metadata_decorator.cc | 34 ++ ...manager_serialization_metadata_decorator.h | 16 + .../policy_tag_manager_serialization_stub.cc | 46 ++ .../policy_tag_manager_serialization_stub.h | 42 +- ..._tag_manager_serialization_stub_factory.cc | 5 +- ...anager_serialization_tracing_connection.cc | 40 ++ ...manager_serialization_tracing_connection.h | 12 + ..._tag_manager_serialization_tracing_stub.cc | 50 ++ ...y_tag_manager_serialization_tracing_stub.h | 16 + .../v1/internal/policy_tag_manager_stub.cc | 46 ++ .../v1/internal/policy_tag_manager_stub.h | 42 +- .../policy_tag_manager_stub_factory.cc | 5 +- .../policy_tag_manager_tracing_connection.cc | 36 ++ .../policy_tag_manager_tracing_connection.h | 12 + .../policy_tag_manager_tracing_stub.cc | 46 ++ .../policy_tag_manager_tracing_stub.h | 16 + .../v1/mocks/mock_data_catalog_connection.h | 15 + .../mock_policy_tag_manager_connection.h | 15 + ...icy_tag_manager_serialization_connection.h | 15 + .../v1/policy_tag_manager_client.cc | 60 +++ .../v1/policy_tag_manager_client.h | 280 ++++++++++ .../v1/policy_tag_manager_connection.cc | 24 + .../v1/policy_tag_manager_connection.h | 12 + ...g_manager_connection_idempotency_policy.cc | 20 + ...ag_manager_connection_idempotency_policy.h | 13 + ...policy_tag_manager_serialization_client.cc | 62 +++ .../policy_tag_manager_serialization_client.h | 280 ++++++++++ ...cy_tag_manager_serialization_connection.cc | 25 + ...icy_tag_manager_serialization_connection.h | 13 + ...alization_connection_idempotency_policy.cc | 24 + ...ialization_connection_idempotency_policy.h | 13 + google/cloud/dataplex/BUILD.bazel | 2 + google/cloud/dataplex/v1/catalog_client.cc | 91 ++++ google/cloud/dataplex/v1/catalog_client.h | 452 ++++++++++++++++ .../cloud/dataplex/v1/catalog_connection.cc | 53 ++ google/cloud/dataplex/v1/catalog_connection.h | 27 + .../catalog_connection_idempotency_policy.cc | 46 ++ .../catalog_connection_idempotency_policy.h | 30 ++ google/cloud/dataplex/v1/content_client.cc | 72 +++ google/cloud/dataplex/v1/content_client.h | 350 +++++++++++++ .../cloud/dataplex/v1/content_connection.cc | 37 ++ google/cloud/dataplex/v1/content_connection.h | 18 + .../content_connection_idempotency_policy.cc | 30 ++ .../content_connection_idempotency_policy.h | 20 + google/cloud/dataplex/v1/data_scan_client.cc | 91 ++++ google/cloud/dataplex/v1/data_scan_client.h | 452 ++++++++++++++++ .../cloud/dataplex/v1/data_scan_connection.cc | 54 ++ .../cloud/dataplex/v1/data_scan_connection.h | 27 + ...data_scan_connection_idempotency_policy.cc | 46 ++ .../data_scan_connection_idempotency_policy.h | 30 ++ .../cloud/dataplex/v1/data_taxonomy_client.cc | 94 ++++ .../cloud/dataplex/v1/data_taxonomy_client.h | 452 ++++++++++++++++ .../dataplex/v1/data_taxonomy_connection.cc | 54 ++ .../dataplex/v1/data_taxonomy_connection.h | 27 + ..._taxonomy_connection_idempotency_policy.cc | 46 ++ ...a_taxonomy_connection_idempotency_policy.h | 30 ++ google/cloud/dataplex/v1/dataplex_client.cc | 91 ++++ google/cloud/dataplex/v1/dataplex_client.h | 452 ++++++++++++++++ .../cloud/dataplex/v1/dataplex_connection.cc | 54 ++ .../cloud/dataplex/v1/dataplex_connection.h | 27 + .../dataplex_connection_idempotency_policy.cc | 46 ++ .../dataplex_connection_idempotency_policy.h | 30 ++ .../v1/internal/catalog_auth_decorator.cc | 75 +++ .../v1/internal/catalog_auth_decorator.h | 36 ++ .../v1/internal/catalog_connection_impl.cc | 161 ++++++ .../v1/internal/catalog_connection_impl.h | 27 + .../v1/internal/catalog_logging_decorator.cc | 102 ++++ .../v1/internal/catalog_logging_decorator.h | 36 ++ .../v1/internal/catalog_metadata_decorator.cc | 78 +++ .../v1/internal/catalog_metadata_decorator.h | 36 ++ .../dataplex/v1/internal/catalog_stub.cc | 105 ++++ .../cloud/dataplex/v1/internal/catalog_stub.h | 92 +++- .../v1/internal/catalog_stub_factory.cc | 11 +- .../v1/internal/catalog_tracing_connection.cc | 81 +++ .../v1/internal/catalog_tracing_connection.h | 27 + .../v1/internal/catalog_tracing_stub.cc | 104 ++++ .../v1/internal/catalog_tracing_stub.h | 36 ++ .../v1/internal/content_auth_decorator.cc | 50 ++ .../v1/internal/content_auth_decorator.h | 24 + .../v1/internal/content_connection_impl.cc | 121 +++++ .../v1/internal/content_connection_impl.h | 18 + .../v1/internal/content_logging_decorator.cc | 68 +++ .../v1/internal/content_logging_decorator.h | 24 + .../v1/internal/content_metadata_decorator.cc | 50 ++ .../v1/internal/content_metadata_decorator.h | 24 + .../dataplex/v1/internal/content_stub.cc | 70 +++ .../cloud/dataplex/v1/internal/content_stub.h | 65 ++- .../v1/internal/content_stub_factory.cc | 10 +- .../v1/internal/content_tracing_connection.cc | 56 ++ .../v1/internal/content_tracing_connection.h | 18 + .../v1/internal/content_tracing_stub.cc | 70 +++ .../v1/internal/content_tracing_stub.h | 24 + .../v1/internal/data_scan_auth_decorator.cc | 75 +++ .../v1/internal/data_scan_auth_decorator.h | 36 ++ .../v1/internal/data_scan_connection_impl.cc | 161 ++++++ .../v1/internal/data_scan_connection_impl.h | 27 + .../internal/data_scan_logging_decorator.cc | 102 ++++ .../v1/internal/data_scan_logging_decorator.h | 36 ++ .../internal/data_scan_metadata_decorator.cc | 79 +++ .../internal/data_scan_metadata_decorator.h | 36 ++ .../dataplex/v1/internal/data_scan_stub.cc | 105 ++++ .../dataplex/v1/internal/data_scan_stub.h | 92 +++- .../v1/internal/data_scan_stub_factory.cc | 11 +- .../internal/data_scan_tracing_connection.cc | 83 +++ .../internal/data_scan_tracing_connection.h | 27 + .../v1/internal/data_scan_tracing_stub.cc | 104 ++++ .../v1/internal/data_scan_tracing_stub.h | 36 ++ .../internal/data_taxonomy_auth_decorator.cc | 76 +++ .../internal/data_taxonomy_auth_decorator.h | 36 ++ .../internal/data_taxonomy_connection_impl.cc | 163 ++++++ .../internal/data_taxonomy_connection_impl.h | 27 + .../data_taxonomy_logging_decorator.cc | 104 ++++ .../data_taxonomy_logging_decorator.h | 36 ++ .../data_taxonomy_metadata_decorator.cc | 80 +++ .../data_taxonomy_metadata_decorator.h | 36 ++ .../v1/internal/data_taxonomy_stub.cc | 105 ++++ .../dataplex/v1/internal/data_taxonomy_stub.h | 92 +++- .../v1/internal/data_taxonomy_stub_factory.cc | 11 +- .../data_taxonomy_tracing_connection.cc | 83 +++ .../data_taxonomy_tracing_connection.h | 27 + .../v1/internal/data_taxonomy_tracing_stub.cc | 104 ++++ .../v1/internal/data_taxonomy_tracing_stub.h | 36 ++ .../v1/internal/dataplex_auth_decorator.cc | 75 +++ .../v1/internal/dataplex_auth_decorator.h | 36 ++ .../v1/internal/dataplex_connection_impl.cc | 161 ++++++ .../v1/internal/dataplex_connection_impl.h | 27 + .../v1/internal/dataplex_logging_decorator.cc | 102 ++++ .../v1/internal/dataplex_logging_decorator.h | 36 ++ .../internal/dataplex_metadata_decorator.cc | 79 +++ .../v1/internal/dataplex_metadata_decorator.h | 36 ++ .../dataplex/v1/internal/dataplex_stub.cc | 105 ++++ .../dataplex/v1/internal/dataplex_stub.h | 92 +++- .../v1/internal/dataplex_stub_factory.cc | 11 +- .../internal/dataplex_tracing_connection.cc | 83 +++ .../v1/internal/dataplex_tracing_connection.h | 27 + .../v1/internal/dataplex_tracing_stub.cc | 104 ++++ .../v1/internal/dataplex_tracing_stub.h | 36 ++ .../v1/internal/metadata_auth_decorator.cc | 75 +++ .../v1/internal/metadata_auth_decorator.h | 36 ++ .../v1/internal/metadata_connection_impl.cc | 161 ++++++ .../v1/internal/metadata_connection_impl.h | 27 + .../v1/internal/metadata_logging_decorator.cc | 102 ++++ .../v1/internal/metadata_logging_decorator.h | 36 ++ .../internal/metadata_metadata_decorator.cc | 79 +++ .../v1/internal/metadata_metadata_decorator.h | 36 ++ .../dataplex/v1/internal/metadata_stub.cc | 105 ++++ .../dataplex/v1/internal/metadata_stub.h | 94 +++- .../v1/internal/metadata_stub_factory.cc | 11 +- .../internal/metadata_tracing_connection.cc | 83 +++ .../v1/internal/metadata_tracing_connection.h | 27 + .../v1/internal/metadata_tracing_stub.cc | 104 ++++ .../v1/internal/metadata_tracing_stub.h | 36 ++ google/cloud/dataplex/v1/metadata_client.cc | 91 ++++ google/cloud/dataplex/v1/metadata_client.h | 453 ++++++++++++++++ .../cloud/dataplex/v1/metadata_connection.cc | 54 ++ .../cloud/dataplex/v1/metadata_connection.h | 27 + .../metadata_connection_idempotency_policy.cc | 46 ++ .../metadata_connection_idempotency_policy.h | 30 ++ .../v1/mocks/mock_catalog_connection.h | 36 ++ .../v1/mocks/mock_content_connection.h | 23 + .../v1/mocks/mock_data_scan_connection.h | 36 ++ .../v1/mocks/mock_data_taxonomy_connection.h | 36 ++ .../v1/mocks/mock_dataplex_connection.h | 36 ++ .../v1/mocks/mock_metadata_connection.h | 36 ++ google/cloud/dataproc/BUILD.bazel | 2 + .../dataproc/v1/autoscaling_policy_client.cc | 81 +++ .../dataproc/v1/autoscaling_policy_client.h | 382 ++++++++++++++ .../v1/autoscaling_policy_connection.cc | 42 ++ .../v1/autoscaling_policy_connection.h | 21 + ...ng_policy_connection_idempotency_policy.cc | 39 ++ ...ing_policy_connection_idempotency_policy.h | 23 + .../dataproc/v1/batch_controller_client.cc | 78 +++ .../dataproc/v1/batch_controller_client.h | 382 ++++++++++++++ .../v1/batch_controller_connection.cc | 40 ++ .../dataproc/v1/batch_controller_connection.h | 21 + ...ontroller_connection_idempotency_policy.cc | 36 ++ ...controller_connection_idempotency_policy.h | 23 + .../dataproc/v1/cluster_controller_client.cc | 79 +++ .../dataproc/v1/cluster_controller_client.h | 382 ++++++++++++++ .../v1/cluster_controller_connection.cc | 40 ++ .../v1/cluster_controller_connection.h | 21 + ...ontroller_connection_idempotency_policy.cc | 36 ++ ...controller_connection_idempotency_policy.h | 23 + .../autoscaling_policy_auth_decorator.cc | 59 +++ .../autoscaling_policy_auth_decorator.h | 28 + .../autoscaling_policy_connection_impl.cc | 116 +++++ .../autoscaling_policy_connection_impl.h | 21 + .../autoscaling_policy_logging_decorator.cc | 80 +++ .../autoscaling_policy_logging_decorator.h | 28 + .../autoscaling_policy_metadata_decorator.cc | 64 +++ .../autoscaling_policy_metadata_decorator.h | 28 + .../v1/internal/autoscaling_policy_stub.cc | 83 +++ .../v1/internal/autoscaling_policy_stub.h | 71 ++- .../autoscaling_policy_stub_factory.cc | 8 +- .../autoscaling_policy_tracing_connection.cc | 63 +++ .../autoscaling_policy_tracing_connection.h | 21 + .../autoscaling_policy_tracing_stub.cc | 83 +++ .../autoscaling_policy_tracing_stub.h | 28 + .../batch_controller_auth_decorator.cc | 58 +++ .../batch_controller_auth_decorator.h | 28 + .../batch_controller_connection_impl.cc | 113 ++++ .../batch_controller_connection_impl.h | 21 + .../batch_controller_logging_decorator.cc | 79 +++ .../batch_controller_logging_decorator.h | 28 + .../batch_controller_metadata_decorator.cc | 61 +++ .../batch_controller_metadata_decorator.h | 28 + .../v1/internal/batch_controller_stub.cc | 81 +++ .../v1/internal/batch_controller_stub.h | 69 ++- .../internal/batch_controller_stub_factory.cc | 8 +- .../batch_controller_tracing_connection.cc | 63 +++ .../batch_controller_tracing_connection.h | 21 + .../internal/batch_controller_tracing_stub.cc | 80 +++ .../internal/batch_controller_tracing_stub.h | 28 + .../cluster_controller_auth_decorator.cc | 58 +++ .../cluster_controller_auth_decorator.h | 28 + .../cluster_controller_connection_impl.cc | 113 ++++ .../cluster_controller_connection_impl.h | 21 + .../cluster_controller_logging_decorator.cc | 79 +++ .../cluster_controller_logging_decorator.h | 28 + .../cluster_controller_metadata_decorator.cc | 62 +++ .../cluster_controller_metadata_decorator.h | 28 + .../v1/internal/cluster_controller_stub.cc | 81 +++ .../v1/internal/cluster_controller_stub.h | 69 ++- .../cluster_controller_stub_factory.cc | 8 +- .../cluster_controller_tracing_connection.cc | 63 +++ .../cluster_controller_tracing_connection.h | 21 + .../cluster_controller_tracing_stub.cc | 80 +++ .../cluster_controller_tracing_stub.h | 28 + .../internal/job_controller_auth_decorator.cc | 58 +++ .../internal/job_controller_auth_decorator.h | 28 + .../job_controller_connection_impl.cc | 113 ++++ .../internal/job_controller_connection_impl.h | 21 + .../job_controller_logging_decorator.cc | 79 +++ .../job_controller_logging_decorator.h | 28 + .../job_controller_metadata_decorator.cc | 61 +++ .../job_controller_metadata_decorator.h | 28 + .../v1/internal/job_controller_stub.cc | 80 +++ .../v1/internal/job_controller_stub.h | 69 ++- .../internal/job_controller_stub_factory.cc | 8 +- .../job_controller_tracing_connection.cc | 61 +++ .../job_controller_tracing_connection.h | 21 + .../internal/job_controller_tracing_stub.cc | 79 +++ .../v1/internal/job_controller_tracing_stub.h | 28 + .../node_group_controller_auth_decorator.cc | 58 +++ .../node_group_controller_auth_decorator.h | 28 + .../node_group_controller_connection_impl.cc | 116 +++++ .../node_group_controller_connection_impl.h | 22 + ...node_group_controller_logging_decorator.cc | 80 +++ .../node_group_controller_logging_decorator.h | 28 + ...ode_group_controller_metadata_decorator.cc | 62 +++ ...node_group_controller_metadata_decorator.h | 28 + .../v1/internal/node_group_controller_stub.cc | 81 +++ .../v1/internal/node_group_controller_stub.h | 69 ++- .../node_group_controller_stub_factory.cc | 8 +- ...ode_group_controller_tracing_connection.cc | 64 +++ ...node_group_controller_tracing_connection.h | 21 + .../node_group_controller_tracing_stub.cc | 80 +++ .../node_group_controller_tracing_stub.h | 28 + .../session_controller_auth_decorator.cc | 58 +++ .../session_controller_auth_decorator.h | 28 + .../session_controller_connection_impl.cc | 113 ++++ .../session_controller_connection_impl.h | 21 + .../session_controller_logging_decorator.cc | 79 +++ .../session_controller_logging_decorator.h | 28 + .../session_controller_metadata_decorator.cc | 62 +++ .../session_controller_metadata_decorator.h | 28 + .../v1/internal/session_controller_stub.cc | 81 +++ .../v1/internal/session_controller_stub.h | 69 ++- .../session_controller_stub_factory.cc | 8 +- .../session_controller_tracing_connection.cc | 63 +++ .../session_controller_tracing_connection.h | 21 + .../session_controller_tracing_stub.cc | 80 +++ .../session_controller_tracing_stub.h | 28 + ...sion_template_controller_auth_decorator.cc | 59 +++ ...ssion_template_controller_auth_decorator.h | 28 + ...ion_template_controller_connection_impl.cc | 116 +++++ ...sion_template_controller_connection_impl.h | 21 + ...n_template_controller_logging_decorator.cc | 82 +++ ...on_template_controller_logging_decorator.h | 28 + ..._template_controller_metadata_decorator.cc | 64 +++ ...n_template_controller_metadata_decorator.h | 28 + .../session_template_controller_stub.cc | 83 +++ .../session_template_controller_stub.h | 71 ++- ...ession_template_controller_stub_factory.cc | 8 +- ..._template_controller_tracing_connection.cc | 63 +++ ...n_template_controller_tracing_connection.h | 21 + ...ession_template_controller_tracing_stub.cc | 83 +++ ...session_template_controller_tracing_stub.h | 28 + .../workflow_template_auth_decorator.cc | 59 +++ .../workflow_template_auth_decorator.h | 28 + .../workflow_template_connection_impl.cc | 115 ++++ .../workflow_template_connection_impl.h | 21 + .../workflow_template_logging_decorator.cc | 80 +++ .../workflow_template_logging_decorator.h | 28 + .../workflow_template_metadata_decorator.cc | 62 +++ .../workflow_template_metadata_decorator.h | 28 + .../v1/internal/workflow_template_stub.cc | 83 +++ .../v1/internal/workflow_template_stub.h | 69 ++- .../workflow_template_stub_factory.cc | 8 +- .../workflow_template_tracing_connection.cc | 63 +++ .../workflow_template_tracing_connection.h | 21 + .../workflow_template_tracing_stub.cc | 82 +++ .../internal/workflow_template_tracing_stub.h | 28 + .../dataproc/v1/job_controller_client.cc | 76 +++ .../cloud/dataproc/v1/job_controller_client.h | 382 ++++++++++++++ .../dataproc/v1/job_controller_connection.cc | 39 ++ .../dataproc/v1/job_controller_connection.h | 21 + ...ontroller_connection_idempotency_policy.cc | 36 ++ ...controller_connection_idempotency_policy.h | 23 + .../mock_autoscaling_policy_connection.h | 28 + .../mocks/mock_batch_controller_connection.h | 28 + .../mock_cluster_controller_connection.h | 28 + .../v1/mocks/mock_job_controller_connection.h | 28 + .../mock_node_group_controller_connection.h | 28 + .../mock_session_controller_connection.h | 28 + ...k_session_template_controller_connection.h | 28 + .../mocks/mock_workflow_template_connection.h | 28 + .../v1/node_group_controller_client.cc | 80 +++ .../v1/node_group_controller_client.h | 382 ++++++++++++++ .../v1/node_group_controller_connection.cc | 41 ++ .../v1/node_group_controller_connection.h | 22 + ...ontroller_connection_idempotency_policy.cc | 36 ++ ...controller_connection_idempotency_policy.h | 23 + .../dataproc/v1/session_controller_client.cc | 79 +++ .../dataproc/v1/session_controller_client.h | 382 ++++++++++++++ .../v1/session_controller_connection.cc | 40 ++ .../v1/session_controller_connection.h | 21 + ...ontroller_connection_idempotency_policy.cc | 36 ++ ...controller_connection_idempotency_policy.h | 23 + .../v1/session_template_controller_client.cc | 81 +++ .../v1/session_template_controller_client.h | 382 ++++++++++++++ .../session_template_controller_connection.cc | 42 ++ .../session_template_controller_connection.h | 21 + ...ontroller_connection_idempotency_policy.cc | 40 ++ ...controller_connection_idempotency_policy.h | 23 + .../dataproc/v1/workflow_template_client.cc | 81 +++ .../dataproc/v1/workflow_template_client.h | 382 ++++++++++++++ .../v1/workflow_template_connection.cc | 42 ++ .../v1/workflow_template_connection.h | 21 + ..._template_connection_idempotency_policy.cc | 37 ++ ...w_template_connection_idempotency_policy.h | 23 + .../admin/v1/datastore_admin_client.cc | 59 +++ .../admin/v1/datastore_admin_client.h | 280 ++++++++++ .../admin/v1/datastore_admin_connection.cc | 23 + .../admin/v1/datastore_admin_connection.h | 12 + ...ore_admin_connection_idempotency_policy.cc | 20 + ...tore_admin_connection_idempotency_policy.h | 13 + .../datastore_admin_auth_decorator.cc | 33 ++ .../internal/datastore_admin_auth_decorator.h | 16 + .../datastore_admin_connection_impl.cc | 73 +++ .../datastore_admin_connection_impl.h | 12 + .../datastore_admin_logging_decorator.cc | 45 ++ .../datastore_admin_logging_decorator.h | 16 + .../datastore_admin_metadata_decorator.cc | 33 ++ .../datastore_admin_metadata_decorator.h | 16 + .../admin/v1/internal/datastore_admin_stub.cc | 46 ++ .../admin/v1/internal/datastore_admin_stub.h | 40 +- .../internal/datastore_admin_stub_factory.cc | 5 +- .../datastore_admin_tracing_connection.cc | 36 ++ .../datastore_admin_tracing_connection.h | 12 + .../internal/datastore_admin_tracing_stub.cc | 46 ++ .../internal/datastore_admin_tracing_stub.h | 16 + .../mocks/mock_datastore_admin_connection.h | 15 + google/cloud/datastore/v1/datastore_client.cc | 55 ++ google/cloud/datastore/v1/datastore_client.h | 280 ++++++++++ .../datastore/v1/datastore_connection.cc | 23 + .../cloud/datastore/v1/datastore_connection.h | 13 + ...datastore_connection_idempotency_policy.cc | 20 + .../datastore_connection_idempotency_policy.h | 13 + .../v1/internal/datastore_auth_decorator.cc | 33 ++ .../v1/internal/datastore_auth_decorator.h | 16 + .../v1/internal/datastore_connection_impl.cc | 73 +++ .../v1/internal/datastore_connection_impl.h | 13 + .../internal/datastore_logging_decorator.cc | 45 ++ .../v1/internal/datastore_logging_decorator.h | 16 + .../internal/datastore_metadata_decorator.cc | 33 ++ .../internal/datastore_metadata_decorator.h | 16 + .../datastore/v1/internal/datastore_stub.cc | 45 ++ .../datastore/v1/internal/datastore_stub.h | 42 +- .../v1/internal/datastore_stub_factory.cc | 7 +- .../internal/datastore_tracing_connection.cc | 37 ++ .../internal/datastore_tracing_connection.h | 12 + .../v1/internal/datastore_tracing_stub.cc | 45 ++ .../v1/internal/datastore_tracing_stub.h | 16 + .../v1/mocks/mock_datastore_connection.h | 15 + google/cloud/datastream/BUILD.bazel | 2 + .../cloud/datastream/v1/datastream_client.cc | 69 +++ .../cloud/datastream/v1/datastream_client.h | 350 +++++++++++++ .../datastream/v1/datastream_connection.cc | 36 ++ .../datastream/v1/datastream_connection.h | 18 + ...atastream_connection_idempotency_policy.cc | 30 ++ ...datastream_connection_idempotency_policy.h | 20 + .../v1/internal/datastream_auth_decorator.cc | 50 ++ .../v1/internal/datastream_auth_decorator.h | 24 + .../v1/internal/datastream_connection_impl.cc | 120 +++++ .../v1/internal/datastream_connection_impl.h | 18 + .../internal/datastream_logging_decorator.cc | 68 +++ .../internal/datastream_logging_decorator.h | 24 + .../internal/datastream_metadata_decorator.cc | 50 ++ .../internal/datastream_metadata_decorator.h | 24 + .../datastream/v1/internal/datastream_stub.cc | 68 +++ .../datastream/v1/internal/datastream_stub.h | 63 ++- .../v1/internal/datastream_stub_factory.cc | 9 +- .../internal/datastream_tracing_connection.cc | 56 ++ .../internal/datastream_tracing_connection.h | 18 + .../v1/internal/datastream_tracing_stub.cc | 68 +++ .../v1/internal/datastream_tracing_stub.h | 24 + .../v1/mocks/mock_datastream_connection.h | 23 + google/cloud/deploy/BUILD.bazel | 2 + google/cloud/deploy/v1/cloud_deploy_client.cc | 88 ++++ google/cloud/deploy/v1/cloud_deploy_client.h | 452 ++++++++++++++++ .../deploy/v1/cloud_deploy_connection.cc | 52 ++ .../cloud/deploy/v1/cloud_deploy_connection.h | 27 + ...ud_deploy_connection_idempotency_policy.cc | 46 ++ ...oud_deploy_connection_idempotency_policy.h | 30 ++ .../internal/cloud_deploy_auth_decorator.cc | 75 +++ .../v1/internal/cloud_deploy_auth_decorator.h | 36 ++ .../internal/cloud_deploy_connection_impl.cc | 161 ++++++ .../internal/cloud_deploy_connection_impl.h | 27 + .../cloud_deploy_logging_decorator.cc | 102 ++++ .../internal/cloud_deploy_logging_decorator.h | 36 ++ .../cloud_deploy_metadata_decorator.cc | 78 +++ .../cloud_deploy_metadata_decorator.h | 36 ++ .../deploy/v1/internal/cloud_deploy_stub.cc | 103 ++++ .../deploy/v1/internal/cloud_deploy_stub.h | 92 +++- .../v1/internal/cloud_deploy_stub_factory.cc | 11 +- .../cloud_deploy_tracing_connection.cc | 81 +++ .../cloud_deploy_tracing_connection.h | 27 + .../v1/internal/cloud_deploy_tracing_stub.cc | 102 ++++ .../v1/internal/cloud_deploy_tracing_stub.h | 36 ++ .../v1/mocks/mock_cloud_deploy_connection.h | 36 ++ google/cloud/developerconnect/BUILD.bazel | 2 + .../v1/developer_connect_client.cc | 73 +++ .../v1/developer_connect_client.h | 350 +++++++++++++ .../v1/developer_connect_connection.cc | 38 ++ .../v1/developer_connect_connection.h | 18 + ...r_connect_connection_idempotency_policy.cc | 30 ++ ...er_connect_connection_idempotency_policy.h | 20 + .../developer_connect_auth_decorator.cc | 50 ++ .../developer_connect_auth_decorator.h | 24 + .../developer_connect_connection_impl.cc | 123 +++++ .../developer_connect_connection_impl.h | 18 + .../developer_connect_logging_decorator.cc | 69 +++ .../developer_connect_logging_decorator.h | 24 + .../developer_connect_metadata_decorator.cc | 51 ++ .../developer_connect_metadata_decorator.h | 24 + .../v1/internal/developer_connect_stub.cc | 70 +++ .../v1/internal/developer_connect_stub.h | 63 ++- .../developer_connect_stub_factory.cc | 9 +- .../developer_connect_tracing_connection.cc | 56 ++ .../developer_connect_tracing_connection.h | 18 + .../developer_connect_tracing_stub.cc | 70 +++ .../internal/developer_connect_tracing_stub.h | 24 + .../mocks/mock_developer_connect_connection.h | 23 + google/cloud/dialogflow_cx/BUILD.bazel | 2 + google/cloud/dialogflow_cx/agents_client.cc | 54 ++ google/cloud/dialogflow_cx/agents_client.h | 296 +++++++++++ .../cloud/dialogflow_cx/agents_connection.cc | 29 ++ .../cloud/dialogflow_cx/agents_connection.h | 15 + .../agents_connection_idempotency_policy.cc | 25 + .../agents_connection_idempotency_policy.h | 17 + .../cloud/dialogflow_cx/changelogs_client.cc | 55 ++ .../cloud/dialogflow_cx/changelogs_client.h | 296 +++++++++++ .../dialogflow_cx/changelogs_connection.cc | 31 ++ .../dialogflow_cx/changelogs_connection.h | 15 + ...hangelogs_connection_idempotency_policy.cc | 25 + ...changelogs_connection_idempotency_policy.h | 17 + .../cloud/dialogflow_cx/deployments_client.cc | 55 ++ .../cloud/dialogflow_cx/deployments_client.h | 296 +++++++++++ .../dialogflow_cx/deployments_connection.cc | 31 ++ .../dialogflow_cx/deployments_connection.h | 15 + ...ployments_connection_idempotency_policy.cc | 25 + ...eployments_connection_idempotency_policy.h | 17 + .../dialogflow_cx/entity_types_client.cc | 55 ++ .../cloud/dialogflow_cx/entity_types_client.h | 296 +++++++++++ .../dialogflow_cx/entity_types_connection.cc | 31 ++ .../dialogflow_cx/entity_types_connection.h | 15 + ...ity_types_connection_idempotency_policy.cc | 25 + ...tity_types_connection_idempotency_policy.h | 17 + .../dialogflow_cx/environments_client.cc | 56 ++ .../cloud/dialogflow_cx/environments_client.h | 296 +++++++++++ .../dialogflow_cx/environments_connection.cc | 31 ++ .../dialogflow_cx/environments_connection.h | 15 + ...ironments_connection_idempotency_policy.cc | 25 + ...vironments_connection_idempotency_policy.h | 17 + .../cloud/dialogflow_cx/experiments_client.cc | 55 ++ .../cloud/dialogflow_cx/experiments_client.h | 296 +++++++++++ .../dialogflow_cx/experiments_connection.cc | 31 ++ .../dialogflow_cx/experiments_connection.h | 15 + ...periments_connection_idempotency_policy.cc | 25 + ...xperiments_connection_idempotency_policy.h | 17 + google/cloud/dialogflow_cx/flows_client.cc | 54 ++ google/cloud/dialogflow_cx/flows_client.h | 296 +++++++++++ .../cloud/dialogflow_cx/flows_connection.cc | 29 ++ google/cloud/dialogflow_cx/flows_connection.h | 15 + .../flows_connection_idempotency_policy.cc | 25 + .../flows_connection_idempotency_policy.h | 17 + .../cloud/dialogflow_cx/generators_client.cc | 55 ++ .../cloud/dialogflow_cx/generators_client.h | 296 +++++++++++ .../dialogflow_cx/generators_connection.cc | 31 ++ .../dialogflow_cx/generators_connection.h | 15 + ...enerators_connection_idempotency_policy.cc | 25 + ...generators_connection_idempotency_policy.h | 17 + google/cloud/dialogflow_cx/intents_client.cc | 54 ++ google/cloud/dialogflow_cx/intents_client.h | 295 +++++++++++ .../cloud/dialogflow_cx/intents_connection.cc | 29 ++ .../cloud/dialogflow_cx/intents_connection.h | 15 + .../intents_connection_idempotency_policy.cc | 25 + .../intents_connection_idempotency_policy.h | 17 + .../internal/agents_auth_decorator.cc | 42 ++ .../internal/agents_auth_decorator.h | 20 + .../internal/agents_connection_impl.cc | 106 ++++ .../internal/agents_connection_impl.h | 15 + .../internal/agents_logging_decorator.cc | 57 ++ .../internal/agents_logging_decorator.h | 20 + .../internal/agents_metadata_decorator.cc | 42 ++ .../internal/agents_metadata_decorator.h | 20 + .../dialogflow_cx/internal/agents_stub.cc | 57 ++ .../dialogflow_cx/internal/agents_stub.h | 55 +- .../internal/agents_stub_factory.cc | 9 +- .../internal/agents_tracing_connection.cc | 47 ++ .../internal/agents_tracing_connection.h | 15 + .../internal/agents_tracing_stub.cc | 57 ++ .../internal/agents_tracing_stub.h | 20 + .../internal/changelogs_auth_decorator.cc | 42 ++ .../internal/changelogs_auth_decorator.h | 20 + .../internal/changelogs_connection_impl.cc | 107 ++++ .../internal/changelogs_connection_impl.h | 15 + .../internal/changelogs_logging_decorator.cc | 57 ++ .../internal/changelogs_logging_decorator.h | 20 + .../internal/changelogs_metadata_decorator.cc | 42 ++ .../internal/changelogs_metadata_decorator.h | 20 + .../dialogflow_cx/internal/changelogs_stub.cc | 57 ++ .../dialogflow_cx/internal/changelogs_stub.h | 57 +- .../internal/changelogs_stub_factory.cc | 10 +- .../internal/changelogs_tracing_connection.cc | 48 ++ .../internal/changelogs_tracing_connection.h | 15 + .../internal/changelogs_tracing_stub.cc | 57 ++ .../internal/changelogs_tracing_stub.h | 20 + .../internal/deployments_auth_decorator.cc | 42 ++ .../internal/deployments_auth_decorator.h | 20 + .../internal/deployments_connection_impl.cc | 108 ++++ .../internal/deployments_connection_impl.h | 15 + .../internal/deployments_logging_decorator.cc | 57 ++ .../internal/deployments_logging_decorator.h | 20 + .../deployments_metadata_decorator.cc | 42 ++ .../internal/deployments_metadata_decorator.h | 20 + .../internal/deployments_stub.cc | 57 ++ .../dialogflow_cx/internal/deployments_stub.h | 57 +- .../internal/deployments_stub_factory.cc | 10 +- .../deployments_tracing_connection.cc | 48 ++ .../internal/deployments_tracing_connection.h | 15 + .../internal/deployments_tracing_stub.cc | 57 ++ .../internal/deployments_tracing_stub.h | 20 + .../internal/entity_types_auth_decorator.cc | 42 ++ .../internal/entity_types_auth_decorator.h | 20 + .../internal/entity_types_connection_impl.cc | 108 ++++ .../internal/entity_types_connection_impl.h | 15 + .../entity_types_logging_decorator.cc | 57 ++ .../internal/entity_types_logging_decorator.h | 20 + .../entity_types_metadata_decorator.cc | 42 ++ .../entity_types_metadata_decorator.h | 20 + .../internal/entity_types_stub.cc | 57 ++ .../internal/entity_types_stub.h | 55 +- .../internal/entity_types_stub_factory.cc | 9 +- .../entity_types_tracing_connection.cc | 48 ++ .../entity_types_tracing_connection.h | 15 + .../internal/entity_types_tracing_stub.cc | 57 ++ .../internal/entity_types_tracing_stub.h | 20 + .../internal/environments_auth_decorator.cc | 42 ++ .../internal/environments_auth_decorator.h | 20 + .../internal/environments_connection_impl.cc | 108 ++++ .../internal/environments_connection_impl.h | 15 + .../environments_logging_decorator.cc | 57 ++ .../internal/environments_logging_decorator.h | 20 + .../environments_metadata_decorator.cc | 42 ++ .../environments_metadata_decorator.h | 20 + .../internal/environments_stub.cc | 58 +++ .../internal/environments_stub.h | 55 +- .../internal/environments_stub_factory.cc | 9 +- .../environments_tracing_connection.cc | 48 ++ .../environments_tracing_connection.h | 15 + .../internal/environments_tracing_stub.cc | 58 +++ .../internal/environments_tracing_stub.h | 20 + .../internal/experiments_auth_decorator.cc | 42 ++ .../internal/experiments_auth_decorator.h | 20 + .../internal/experiments_connection_impl.cc | 108 ++++ .../internal/experiments_connection_impl.h | 15 + .../internal/experiments_logging_decorator.cc | 57 ++ .../internal/experiments_logging_decorator.h | 20 + .../experiments_metadata_decorator.cc | 42 ++ .../internal/experiments_metadata_decorator.h | 20 + .../internal/experiments_stub.cc | 57 ++ .../dialogflow_cx/internal/experiments_stub.h | 57 +- .../internal/experiments_stub_factory.cc | 10 +- .../experiments_tracing_connection.cc | 48 ++ .../internal/experiments_tracing_connection.h | 15 + .../internal/experiments_tracing_stub.cc | 57 ++ .../internal/experiments_tracing_stub.h | 20 + .../internal/flows_auth_decorator.cc | 41 ++ .../internal/flows_auth_decorator.h | 20 + .../internal/flows_connection_impl.cc | 105 ++++ .../internal/flows_connection_impl.h | 15 + .../internal/flows_logging_decorator.cc | 57 ++ .../internal/flows_logging_decorator.h | 20 + .../internal/flows_metadata_decorator.cc | 42 ++ .../internal/flows_metadata_decorator.h | 20 + .../dialogflow_cx/internal/flows_stub.cc | 57 ++ .../cloud/dialogflow_cx/internal/flows_stub.h | 55 +- .../internal/flows_stub_factory.cc | 9 +- .../internal/flows_tracing_connection.cc | 45 ++ .../internal/flows_tracing_connection.h | 15 + .../internal/flows_tracing_stub.cc | 57 ++ .../internal/flows_tracing_stub.h | 20 + .../internal/generators_auth_decorator.cc | 42 ++ .../internal/generators_auth_decorator.h | 20 + .../internal/generators_connection_impl.cc | 107 ++++ .../internal/generators_connection_impl.h | 15 + .../internal/generators_logging_decorator.cc | 57 ++ .../internal/generators_logging_decorator.h | 20 + .../internal/generators_metadata_decorator.cc | 42 ++ .../internal/generators_metadata_decorator.h | 20 + .../dialogflow_cx/internal/generators_stub.cc | 57 ++ .../dialogflow_cx/internal/generators_stub.h | 57 +- .../internal/generators_stub_factory.cc | 10 +- .../internal/generators_tracing_connection.cc | 48 ++ .../internal/generators_tracing_connection.h | 15 + .../internal/generators_tracing_stub.cc | 57 ++ .../internal/generators_tracing_stub.h | 20 + .../internal/intents_auth_decorator.cc | 42 ++ .../internal/intents_auth_decorator.h | 20 + .../internal/intents_connection_impl.cc | 106 ++++ .../internal/intents_connection_impl.h | 15 + .../internal/intents_logging_decorator.cc | 57 ++ .../internal/intents_logging_decorator.h | 20 + .../internal/intents_metadata_decorator.cc | 42 ++ .../internal/intents_metadata_decorator.h | 20 + .../dialogflow_cx/internal/intents_stub.cc | 57 ++ .../dialogflow_cx/internal/intents_stub.h | 55 +- .../internal/intents_stub_factory.cc | 9 +- .../internal/intents_tracing_connection.cc | 47 ++ .../internal/intents_tracing_connection.h | 15 + .../internal/intents_tracing_stub.cc | 57 ++ .../internal/intents_tracing_stub.h | 20 + .../internal/pages_auth_decorator.cc | 41 ++ .../internal/pages_auth_decorator.h | 20 + .../internal/pages_connection_impl.cc | 105 ++++ .../internal/pages_connection_impl.h | 15 + .../internal/pages_logging_decorator.cc | 57 ++ .../internal/pages_logging_decorator.h | 20 + .../internal/pages_metadata_decorator.cc | 42 ++ .../internal/pages_metadata_decorator.h | 20 + .../dialogflow_cx/internal/pages_stub.cc | 57 ++ .../cloud/dialogflow_cx/internal/pages_stub.h | 57 +- .../internal/pages_stub_factory.cc | 11 +- .../internal/pages_tracing_connection.cc | 45 ++ .../internal/pages_tracing_connection.h | 15 + .../internal/pages_tracing_stub.cc | 57 ++ .../internal/pages_tracing_stub.h | 20 + .../security_settings_auth_decorator.cc | 44 ++ .../security_settings_auth_decorator.h | 20 + .../security_settings_connection_impl.cc | 110 ++++ .../security_settings_connection_impl.h | 15 + .../security_settings_logging_decorator.cc | 59 +++ .../security_settings_logging_decorator.h | 20 + .../security_settings_metadata_decorator.cc | 44 ++ .../security_settings_metadata_decorator.h | 20 + .../internal/security_settings_stub.cc | 59 +++ .../internal/security_settings_stub.h | 57 +- .../security_settings_stub_factory.cc | 9 +- .../security_settings_tracing_connection.cc | 48 ++ .../security_settings_tracing_connection.h | 15 + .../security_settings_tracing_stub.cc | 61 +++ .../internal/security_settings_tracing_stub.h | 20 + .../session_entity_types_auth_decorator.cc | 42 ++ .../session_entity_types_auth_decorator.h | 20 + .../session_entity_types_connection_impl.cc | 108 ++++ .../session_entity_types_connection_impl.h | 15 + .../session_entity_types_logging_decorator.cc | 59 +++ .../session_entity_types_logging_decorator.h | 20 + ...session_entity_types_metadata_decorator.cc | 44 ++ .../session_entity_types_metadata_decorator.h | 20 + .../internal/session_entity_types_stub.cc | 59 +++ .../internal/session_entity_types_stub.h | 57 +- .../session_entity_types_stub_factory.cc | 9 +- ...session_entity_types_tracing_connection.cc | 48 ++ .../session_entity_types_tracing_connection.h | 15 + .../session_entity_types_tracing_stub.cc | 59 +++ .../session_entity_types_tracing_stub.h | 20 + .../internal/sessions_auth_decorator.cc | 42 ++ .../internal/sessions_auth_decorator.h | 20 + .../internal/sessions_connection_impl.cc | 107 ++++ .../internal/sessions_connection_impl.h | 15 + .../internal/sessions_logging_decorator.cc | 57 ++ .../internal/sessions_logging_decorator.h | 20 + .../internal/sessions_metadata_decorator.cc | 42 ++ .../internal/sessions_metadata_decorator.h | 20 + .../dialogflow_cx/internal/sessions_stub.cc | 57 ++ .../dialogflow_cx/internal/sessions_stub.h | 57 +- .../internal/sessions_stub_factory.cc | 11 +- .../internal/sessions_tracing_connection.cc | 48 ++ .../internal/sessions_tracing_connection.h | 15 + .../internal/sessions_tracing_stub.cc | 57 ++ .../internal/sessions_tracing_stub.h | 20 + .../internal/test_cases_auth_decorator.cc | 42 ++ .../internal/test_cases_auth_decorator.h | 20 + .../internal/test_cases_connection_impl.cc | 107 ++++ .../internal/test_cases_connection_impl.h | 15 + .../internal/test_cases_logging_decorator.cc | 57 ++ .../internal/test_cases_logging_decorator.h | 20 + .../internal/test_cases_metadata_decorator.cc | 42 ++ .../internal/test_cases_metadata_decorator.h | 20 + .../dialogflow_cx/internal/test_cases_stub.cc | 57 ++ .../dialogflow_cx/internal/test_cases_stub.h | 55 +- .../internal/test_cases_stub_factory.cc | 9 +- .../internal/test_cases_tracing_connection.cc | 48 ++ .../internal/test_cases_tracing_connection.h | 15 + .../internal/test_cases_tracing_stub.cc | 57 ++ .../internal/test_cases_tracing_stub.h | 20 + .../transition_route_groups_auth_decorator.cc | 44 ++ .../transition_route_groups_auth_decorator.h | 20 + ...transition_route_groups_connection_impl.cc | 108 ++++ .../transition_route_groups_connection_impl.h | 15 + ...ansition_route_groups_logging_decorator.cc | 59 +++ ...ransition_route_groups_logging_decorator.h | 20 + ...nsition_route_groups_metadata_decorator.cc | 44 ++ ...ansition_route_groups_metadata_decorator.h | 20 + .../internal/transition_route_groups_stub.cc | 59 +++ .../internal/transition_route_groups_stub.h | 57 +- .../transition_route_groups_stub_factory.cc | 9 +- ...nsition_route_groups_tracing_connection.cc | 48 ++ ...ansition_route_groups_tracing_connection.h | 15 + .../transition_route_groups_tracing_stub.cc | 59 +++ .../transition_route_groups_tracing_stub.h | 20 + .../internal/versions_auth_decorator.cc | 42 ++ .../internal/versions_auth_decorator.h | 20 + .../internal/versions_connection_impl.cc | 106 ++++ .../internal/versions_connection_impl.h | 15 + .../internal/versions_logging_decorator.cc | 57 ++ .../internal/versions_logging_decorator.h | 20 + .../internal/versions_metadata_decorator.cc | 42 ++ .../internal/versions_metadata_decorator.h | 20 + .../dialogflow_cx/internal/versions_stub.cc | 57 ++ .../dialogflow_cx/internal/versions_stub.h | 55 +- .../internal/versions_stub_factory.cc | 9 +- .../internal/versions_tracing_connection.cc | 48 ++ .../internal/versions_tracing_connection.h | 15 + .../internal/versions_tracing_stub.cc | 57 ++ .../internal/versions_tracing_stub.h | 20 + .../internal/webhooks_auth_decorator.cc | 42 ++ .../internal/webhooks_auth_decorator.h | 20 + .../internal/webhooks_connection_impl.cc | 106 ++++ .../internal/webhooks_connection_impl.h | 15 + .../internal/webhooks_logging_decorator.cc | 57 ++ .../internal/webhooks_logging_decorator.h | 20 + .../internal/webhooks_metadata_decorator.cc | 42 ++ .../internal/webhooks_metadata_decorator.h | 20 + .../dialogflow_cx/internal/webhooks_stub.cc | 57 ++ .../dialogflow_cx/internal/webhooks_stub.h | 57 +- .../internal/webhooks_stub_factory.cc | 11 +- .../internal/webhooks_tracing_connection.cc | 48 ++ .../internal/webhooks_tracing_connection.h | 15 + .../internal/webhooks_tracing_stub.cc | 57 ++ .../internal/webhooks_tracing_stub.h | 20 + .../mocks/mock_agents_connection.h | 19 + .../mocks/mock_changelogs_connection.h | 19 + .../mocks/mock_deployments_connection.h | 19 + .../mocks/mock_entity_types_connection.h | 19 + .../mocks/mock_environments_connection.h | 19 + .../mocks/mock_experiments_connection.h | 19 + .../mocks/mock_flows_connection.h | 19 + .../mocks/mock_generators_connection.h | 19 + .../mocks/mock_intents_connection.h | 19 + .../mocks/mock_pages_connection.h | 19 + .../mocks/mock_security_settings_connection.h | 19 + .../mock_session_entity_types_connection.h | 19 + .../mocks/mock_sessions_connection.h | 19 + .../mocks/mock_test_cases_connection.h | 19 + .../mock_transition_route_groups_connection.h | 19 + .../mocks/mock_versions_connection.h | 19 + .../mocks/mock_webhooks_connection.h | 19 + google/cloud/dialogflow_cx/pages_client.cc | 54 ++ google/cloud/dialogflow_cx/pages_client.h | 296 +++++++++++ .../cloud/dialogflow_cx/pages_connection.cc | 29 ++ google/cloud/dialogflow_cx/pages_connection.h | 15 + .../pages_connection_idempotency_policy.cc | 25 + .../pages_connection_idempotency_policy.h | 17 + .../dialogflow_cx/security_settings_client.cc | 62 +++ .../dialogflow_cx/security_settings_client.h | 296 +++++++++++ .../security_settings_connection.cc | 33 ++ .../security_settings_connection.h | 15 + ..._settings_connection_idempotency_policy.cc | 25 + ...y_settings_connection_idempotency_policy.h | 17 + .../session_entity_types_client.cc | 60 +++ .../session_entity_types_client.h | 296 +++++++++++ .../session_entity_types_connection.cc | 33 ++ .../session_entity_types_connection.h | 15 + ...ity_types_connection_idempotency_policy.cc | 25 + ...tity_types_connection_idempotency_policy.h | 17 + google/cloud/dialogflow_cx/sessions_client.cc | 54 ++ google/cloud/dialogflow_cx/sessions_client.h | 296 +++++++++++ .../dialogflow_cx/sessions_connection.cc | 31 ++ .../cloud/dialogflow_cx/sessions_connection.h | 15 + .../sessions_connection_idempotency_policy.cc | 25 + .../sessions_connection_idempotency_policy.h | 17 + .../cloud/dialogflow_cx/test_cases_client.cc | 54 ++ .../cloud/dialogflow_cx/test_cases_client.h | 296 +++++++++++ .../dialogflow_cx/test_cases_connection.cc | 30 ++ .../dialogflow_cx/test_cases_connection.h | 15 + ...est_cases_connection_idempotency_policy.cc | 25 + ...test_cases_connection_idempotency_policy.h | 17 + .../transition_route_groups_client.cc | 62 +++ .../transition_route_groups_client.h | 296 +++++++++++ .../transition_route_groups_connection.cc | 33 ++ .../transition_route_groups_connection.h | 15 + ...te_groups_connection_idempotency_policy.cc | 25 + ...ute_groups_connection_idempotency_policy.h | 17 + google/cloud/dialogflow_cx/versions_client.cc | 54 ++ google/cloud/dialogflow_cx/versions_client.h | 296 +++++++++++ .../dialogflow_cx/versions_connection.cc | 30 ++ .../cloud/dialogflow_cx/versions_connection.h | 15 + .../versions_connection_idempotency_policy.cc | 25 + .../versions_connection_idempotency_policy.h | 17 + google/cloud/dialogflow_cx/webhooks_client.cc | 54 ++ google/cloud/dialogflow_cx/webhooks_client.h | 296 +++++++++++ .../dialogflow_cx/webhooks_connection.cc | 30 ++ .../cloud/dialogflow_cx/webhooks_connection.h | 15 + .../webhooks_connection_idempotency_policy.cc | 25 + .../webhooks_connection_idempotency_policy.h | 17 + google/cloud/dialogflow_es/BUILD.bazel | 2 + google/cloud/dialogflow_es/agents_client.cc | 54 ++ google/cloud/dialogflow_es/agents_client.h | 296 +++++++++++ .../cloud/dialogflow_es/agents_connection.cc | 29 ++ .../cloud/dialogflow_es/agents_connection.h | 15 + .../agents_connection_idempotency_policy.cc | 25 + .../agents_connection_idempotency_policy.h | 17 + .../dialogflow_es/answer_records_client.cc | 56 ++ .../dialogflow_es/answer_records_client.h | 296 +++++++++++ .../answer_records_connection.cc | 32 ++ .../dialogflow_es/answer_records_connection.h | 15 + ...r_records_connection_idempotency_policy.cc | 25 + ...er_records_connection_idempotency_policy.h | 17 + google/cloud/dialogflow_es/contexts_client.cc | 54 ++ google/cloud/dialogflow_es/contexts_client.h | 296 +++++++++++ .../dialogflow_es/contexts_connection.cc | 30 ++ .../cloud/dialogflow_es/contexts_connection.h | 15 + .../contexts_connection_idempotency_policy.cc | 25 + .../contexts_connection_idempotency_policy.h | 17 + .../conversation_datasets_client.cc | 62 +++ .../conversation_datasets_client.h | 296 +++++++++++ .../conversation_datasets_connection.cc | 33 ++ .../conversation_datasets_connection.h | 15 + ..._datasets_connection_idempotency_policy.cc | 25 + ...n_datasets_connection_idempotency_policy.h | 17 + .../conversation_models_client.cc | 60 +++ .../conversation_models_client.h | 296 +++++++++++ .../conversation_models_connection.cc | 33 ++ .../conversation_models_connection.h | 15 + ...on_models_connection_idempotency_policy.cc | 25 + ...ion_models_connection_idempotency_policy.h | 17 + .../conversation_profiles_client.cc | 62 +++ .../conversation_profiles_client.h | 296 +++++++++++ .../conversation_profiles_connection.cc | 33 ++ .../conversation_profiles_connection.h | 15 + ..._profiles_connection_idempotency_policy.cc | 25 + ...n_profiles_connection_idempotency_policy.h | 17 + .../dialogflow_es/conversations_client.cc | 56 ++ .../dialogflow_es/conversations_client.h | 296 +++++++++++ .../dialogflow_es/conversations_connection.cc | 32 ++ .../dialogflow_es/conversations_connection.h | 15 + ...ersations_connection_idempotency_policy.cc | 25 + ...versations_connection_idempotency_policy.h | 17 + .../cloud/dialogflow_es/documents_client.cc | 54 ++ google/cloud/dialogflow_es/documents_client.h | 295 +++++++++++ .../dialogflow_es/documents_connection.cc | 30 ++ .../dialogflow_es/documents_connection.h | 15 + ...documents_connection_idempotency_policy.cc | 25 + .../documents_connection_idempotency_policy.h | 17 + .../dialogflow_es/entity_types_client.cc | 55 ++ .../cloud/dialogflow_es/entity_types_client.h | 296 +++++++++++ .../dialogflow_es/entity_types_connection.cc | 31 ++ .../dialogflow_es/entity_types_connection.h | 15 + ...ity_types_connection_idempotency_policy.cc | 25 + ...tity_types_connection_idempotency_policy.h | 17 + .../dialogflow_es/environments_client.cc | 56 ++ .../cloud/dialogflow_es/environments_client.h | 296 +++++++++++ .../dialogflow_es/environments_connection.cc | 31 ++ .../dialogflow_es/environments_connection.h | 15 + ...ironments_connection_idempotency_policy.cc | 25 + ...vironments_connection_idempotency_policy.h | 17 + .../dialogflow_es/fulfillments_client.cc | 56 ++ .../cloud/dialogflow_es/fulfillments_client.h | 296 +++++++++++ .../dialogflow_es/fulfillments_connection.cc | 32 ++ .../dialogflow_es/fulfillments_connection.h | 16 + ...fillments_connection_idempotency_policy.cc | 25 + ...lfillments_connection_idempotency_policy.h | 17 + google/cloud/dialogflow_es/intents_client.cc | 54 ++ google/cloud/dialogflow_es/intents_client.h | 296 +++++++++++ .../cloud/dialogflow_es/intents_connection.cc | 29 ++ .../cloud/dialogflow_es/intents_connection.h | 15 + .../intents_connection_idempotency_policy.cc | 25 + .../intents_connection_idempotency_policy.h | 17 + .../internal/agents_auth_decorator.cc | 42 ++ .../internal/agents_auth_decorator.h | 20 + .../internal/agents_connection_impl.cc | 106 ++++ .../internal/agents_connection_impl.h | 15 + .../internal/agents_logging_decorator.cc | 57 ++ .../internal/agents_logging_decorator.h | 20 + .../internal/agents_metadata_decorator.cc | 42 ++ .../internal/agents_metadata_decorator.h | 20 + .../dialogflow_es/internal/agents_stub.cc | 57 ++ .../dialogflow_es/internal/agents_stub.h | 55 +- .../internal/agents_stub_factory.cc | 9 +- .../internal/agents_tracing_connection.cc | 47 ++ .../internal/agents_tracing_connection.h | 15 + .../internal/agents_tracing_stub.cc | 57 ++ .../internal/agents_tracing_stub.h | 20 + .../internal/answer_records_auth_decorator.cc | 42 ++ .../internal/answer_records_auth_decorator.h | 20 + .../answer_records_connection_impl.cc | 108 ++++ .../internal/answer_records_connection_impl.h | 15 + .../answer_records_logging_decorator.cc | 57 ++ .../answer_records_logging_decorator.h | 20 + .../answer_records_metadata_decorator.cc | 42 ++ .../answer_records_metadata_decorator.h | 20 + .../internal/answer_records_stub.cc | 58 +++ .../internal/answer_records_stub.h | 57 +- .../internal/answer_records_stub_factory.cc | 10 +- .../answer_records_tracing_connection.cc | 48 ++ .../answer_records_tracing_connection.h | 15 + .../internal/answer_records_tracing_stub.cc | 58 +++ .../internal/answer_records_tracing_stub.h | 20 + .../internal/contexts_auth_decorator.cc | 42 ++ .../internal/contexts_auth_decorator.h | 20 + .../internal/contexts_connection_impl.cc | 106 ++++ .../internal/contexts_connection_impl.h | 15 + .../internal/contexts_logging_decorator.cc | 57 ++ .../internal/contexts_logging_decorator.h | 20 + .../internal/contexts_metadata_decorator.cc | 42 ++ .../internal/contexts_metadata_decorator.h | 20 + .../dialogflow_es/internal/contexts_stub.cc | 57 ++ .../dialogflow_es/internal/contexts_stub.h | 57 +- .../internal/contexts_stub_factory.cc | 11 +- .../internal/contexts_tracing_connection.cc | 48 ++ .../internal/contexts_tracing_connection.h | 15 + .../internal/contexts_tracing_stub.cc | 57 ++ .../internal/contexts_tracing_stub.h | 20 + .../conversation_datasets_auth_decorator.cc | 43 ++ .../conversation_datasets_auth_decorator.h | 20 + .../conversation_datasets_connection_impl.cc | 108 ++++ .../conversation_datasets_connection_impl.h | 15 + ...conversation_datasets_logging_decorator.cc | 59 +++ .../conversation_datasets_logging_decorator.h | 20 + ...onversation_datasets_metadata_decorator.cc | 44 ++ ...conversation_datasets_metadata_decorator.h | 20 + .../internal/conversation_datasets_stub.cc | 59 +++ .../internal/conversation_datasets_stub.h | 55 +- .../conversation_datasets_stub_factory.cc | 9 +- ...onversation_datasets_tracing_connection.cc | 48 ++ ...conversation_datasets_tracing_connection.h | 15 + .../conversation_datasets_tracing_stub.cc | 59 +++ .../conversation_datasets_tracing_stub.h | 20 + .../conversation_models_auth_decorator.cc | 42 ++ .../conversation_models_auth_decorator.h | 20 + .../conversation_models_connection_impl.cc | 108 ++++ .../conversation_models_connection_impl.h | 15 + .../conversation_models_logging_decorator.cc | 59 +++ .../conversation_models_logging_decorator.h | 20 + .../conversation_models_metadata_decorator.cc | 44 ++ .../conversation_models_metadata_decorator.h | 20 + .../internal/conversation_models_stub.cc | 59 +++ .../internal/conversation_models_stub.h | 55 +- .../conversation_models_stub_factory.cc | 9 +- .../conversation_models_tracing_connection.cc | 48 ++ .../conversation_models_tracing_connection.h | 15 + .../conversation_models_tracing_stub.cc | 59 +++ .../conversation_models_tracing_stub.h | 20 + .../conversation_profiles_auth_decorator.cc | 43 ++ .../conversation_profiles_auth_decorator.h | 20 + .../conversation_profiles_connection_impl.cc | 108 ++++ .../conversation_profiles_connection_impl.h | 15 + ...conversation_profiles_logging_decorator.cc | 59 +++ .../conversation_profiles_logging_decorator.h | 20 + ...onversation_profiles_metadata_decorator.cc | 44 ++ ...conversation_profiles_metadata_decorator.h | 20 + .../internal/conversation_profiles_stub.cc | 59 +++ .../internal/conversation_profiles_stub.h | 55 +- .../conversation_profiles_stub_factory.cc | 9 +- ...onversation_profiles_tracing_connection.cc | 48 ++ ...conversation_profiles_tracing_connection.h | 15 + .../conversation_profiles_tracing_stub.cc | 59 +++ .../conversation_profiles_tracing_stub.h | 20 + .../internal/conversations_auth_decorator.cc | 42 ++ .../internal/conversations_auth_decorator.h | 20 + .../internal/conversations_connection_impl.cc | 108 ++++ .../internal/conversations_connection_impl.h | 15 + .../conversations_logging_decorator.cc | 57 ++ .../conversations_logging_decorator.h | 20 + .../conversations_metadata_decorator.cc | 42 ++ .../conversations_metadata_decorator.h | 20 + .../internal/conversations_stub.cc | 58 +++ .../internal/conversations_stub.h | 57 +- .../internal/conversations_stub_factory.cc | 10 +- .../conversations_tracing_connection.cc | 48 ++ .../conversations_tracing_connection.h | 15 + .../internal/conversations_tracing_stub.cc | 58 +++ .../internal/conversations_tracing_stub.h | 20 + .../internal/documents_auth_decorator.cc | 42 ++ .../internal/documents_auth_decorator.h | 20 + .../internal/documents_connection_impl.cc | 107 ++++ .../internal/documents_connection_impl.h | 15 + .../internal/documents_logging_decorator.cc | 57 ++ .../internal/documents_logging_decorator.h | 20 + .../internal/documents_metadata_decorator.cc | 42 ++ .../internal/documents_metadata_decorator.h | 20 + .../dialogflow_es/internal/documents_stub.cc | 57 ++ .../dialogflow_es/internal/documents_stub.h | 55 +- .../internal/documents_stub_factory.cc | 9 +- .../internal/documents_tracing_connection.cc | 48 ++ .../internal/documents_tracing_connection.h | 15 + .../internal/documents_tracing_stub.cc | 57 ++ .../internal/documents_tracing_stub.h | 20 + .../internal/entity_types_auth_decorator.cc | 42 ++ .../internal/entity_types_auth_decorator.h | 20 + .../internal/entity_types_connection_impl.cc | 108 ++++ .../internal/entity_types_connection_impl.h | 15 + .../entity_types_logging_decorator.cc | 57 ++ .../internal/entity_types_logging_decorator.h | 20 + .../entity_types_metadata_decorator.cc | 42 ++ .../entity_types_metadata_decorator.h | 20 + .../internal/entity_types_stub.cc | 57 ++ .../internal/entity_types_stub.h | 55 +- .../internal/entity_types_stub_factory.cc | 9 +- .../entity_types_tracing_connection.cc | 48 ++ .../entity_types_tracing_connection.h | 15 + .../internal/entity_types_tracing_stub.cc | 57 ++ .../internal/entity_types_tracing_stub.h | 20 + .../internal/environments_auth_decorator.cc | 42 ++ .../internal/environments_auth_decorator.h | 20 + .../internal/environments_connection_impl.cc | 108 ++++ .../internal/environments_connection_impl.h | 15 + .../environments_logging_decorator.cc | 57 ++ .../internal/environments_logging_decorator.h | 20 + .../environments_metadata_decorator.cc | 42 ++ .../environments_metadata_decorator.h | 20 + .../internal/environments_stub.cc | 58 +++ .../internal/environments_stub.h | 57 +- .../internal/environments_stub_factory.cc | 10 +- .../environments_tracing_connection.cc | 48 ++ .../environments_tracing_connection.h | 15 + .../internal/environments_tracing_stub.cc | 58 +++ .../internal/environments_tracing_stub.h | 20 + .../internal/fulfillments_auth_decorator.cc | 42 ++ .../internal/fulfillments_auth_decorator.h | 20 + .../internal/fulfillments_connection_impl.cc | 109 ++++ .../internal/fulfillments_connection_impl.h | 16 + .../fulfillments_logging_decorator.cc | 57 ++ .../internal/fulfillments_logging_decorator.h | 20 + .../fulfillments_metadata_decorator.cc | 42 ++ .../fulfillments_metadata_decorator.h | 20 + .../internal/fulfillments_stub.cc | 58 +++ .../internal/fulfillments_stub.h | 57 +- .../internal/fulfillments_stub_factory.cc | 10 +- .../fulfillments_tracing_connection.cc | 49 ++ .../fulfillments_tracing_connection.h | 15 + .../internal/fulfillments_tracing_stub.cc | 58 +++ .../internal/fulfillments_tracing_stub.h | 20 + .../internal/intents_auth_decorator.cc | 42 ++ .../internal/intents_auth_decorator.h | 20 + .../internal/intents_connection_impl.cc | 106 ++++ .../internal/intents_connection_impl.h | 15 + .../internal/intents_logging_decorator.cc | 57 ++ .../internal/intents_logging_decorator.h | 20 + .../internal/intents_metadata_decorator.cc | 42 ++ .../internal/intents_metadata_decorator.h | 20 + .../dialogflow_es/internal/intents_stub.cc | 57 ++ .../dialogflow_es/internal/intents_stub.h | 55 +- .../internal/intents_stub_factory.cc | 9 +- .../internal/intents_tracing_connection.cc | 47 ++ .../internal/intents_tracing_connection.h | 15 + .../internal/intents_tracing_stub.cc | 57 ++ .../internal/intents_tracing_stub.h | 20 + .../knowledge_bases_auth_decorator.cc | 42 ++ .../internal/knowledge_bases_auth_decorator.h | 20 + .../knowledge_bases_connection_impl.cc | 108 ++++ .../knowledge_bases_connection_impl.h | 15 + .../knowledge_bases_logging_decorator.cc | 57 ++ .../knowledge_bases_logging_decorator.h | 20 + .../knowledge_bases_metadata_decorator.cc | 42 ++ .../knowledge_bases_metadata_decorator.h | 20 + .../internal/knowledge_bases_stub.cc | 59 +++ .../internal/knowledge_bases_stub.h | 57 +- .../internal/knowledge_bases_stub_factory.cc | 10 +- .../knowledge_bases_tracing_connection.cc | 48 ++ .../knowledge_bases_tracing_connection.h | 15 + .../internal/knowledge_bases_tracing_stub.cc | 59 +++ .../internal/knowledge_bases_tracing_stub.h | 20 + .../internal/participants_auth_decorator.cc | 42 ++ .../internal/participants_auth_decorator.h | 20 + .../internal/participants_connection_impl.cc | 108 ++++ .../internal/participants_connection_impl.h | 15 + .../participants_logging_decorator.cc | 57 ++ .../internal/participants_logging_decorator.h | 20 + .../participants_metadata_decorator.cc | 42 ++ .../participants_metadata_decorator.h | 20 + .../internal/participants_stub.cc | 58 +++ .../internal/participants_stub.h | 57 +- .../internal/participants_stub_factory.cc | 10 +- .../participants_tracing_connection.cc | 48 ++ .../participants_tracing_connection.h | 15 + .../internal/participants_tracing_stub.cc | 58 +++ .../internal/participants_tracing_stub.h | 20 + .../session_entity_types_auth_decorator.cc | 42 ++ .../session_entity_types_auth_decorator.h | 20 + .../session_entity_types_connection_impl.cc | 108 ++++ .../session_entity_types_connection_impl.h | 15 + .../session_entity_types_logging_decorator.cc | 59 +++ .../session_entity_types_logging_decorator.h | 20 + ...session_entity_types_metadata_decorator.cc | 44 ++ .../session_entity_types_metadata_decorator.h | 20 + .../internal/session_entity_types_stub.cc | 59 +++ .../internal/session_entity_types_stub.h | 57 +- .../session_entity_types_stub_factory.cc | 9 +- ...session_entity_types_tracing_connection.cc | 48 ++ .../session_entity_types_tracing_connection.h | 15 + .../session_entity_types_tracing_stub.cc | 59 +++ .../session_entity_types_tracing_stub.h | 20 + .../internal/sessions_auth_decorator.cc | 42 ++ .../internal/sessions_auth_decorator.h | 20 + .../internal/sessions_connection_impl.cc | 107 ++++ .../internal/sessions_connection_impl.h | 16 + .../internal/sessions_logging_decorator.cc | 57 ++ .../internal/sessions_logging_decorator.h | 20 + .../internal/sessions_metadata_decorator.cc | 42 ++ .../internal/sessions_metadata_decorator.h | 20 + .../dialogflow_es/internal/sessions_stub.cc | 57 ++ .../dialogflow_es/internal/sessions_stub.h | 57 +- .../internal/sessions_stub_factory.cc | 11 +- .../internal/sessions_tracing_connection.cc | 49 ++ .../internal/sessions_tracing_connection.h | 15 + .../internal/sessions_tracing_stub.cc | 57 ++ .../internal/sessions_tracing_stub.h | 20 + .../internal/versions_auth_decorator.cc | 42 ++ .../internal/versions_auth_decorator.h | 20 + .../internal/versions_connection_impl.cc | 106 ++++ .../internal/versions_connection_impl.h | 15 + .../internal/versions_logging_decorator.cc | 57 ++ .../internal/versions_logging_decorator.h | 20 + .../internal/versions_metadata_decorator.cc | 42 ++ .../internal/versions_metadata_decorator.h | 20 + .../dialogflow_es/internal/versions_stub.cc | 57 ++ .../dialogflow_es/internal/versions_stub.h | 57 +- .../internal/versions_stub_factory.cc | 11 +- .../internal/versions_tracing_connection.cc | 48 ++ .../internal/versions_tracing_connection.h | 15 + .../internal/versions_tracing_stub.cc | 57 ++ .../internal/versions_tracing_stub.h | 20 + .../dialogflow_es/knowledge_bases_client.cc | 58 +++ .../dialogflow_es/knowledge_bases_client.h | 296 +++++++++++ .../knowledge_bases_connection.cc | 32 ++ .../knowledge_bases_connection.h | 15 + ...dge_bases_connection_idempotency_policy.cc | 25 + ...edge_bases_connection_idempotency_policy.h | 17 + .../mocks/mock_agents_connection.h | 19 + .../mocks/mock_answer_records_connection.h | 19 + .../mocks/mock_contexts_connection.h | 19 + .../mock_conversation_datasets_connection.h | 19 + .../mock_conversation_models_connection.h | 19 + .../mock_conversation_profiles_connection.h | 19 + .../mocks/mock_conversations_connection.h | 19 + .../mocks/mock_documents_connection.h | 19 + .../mocks/mock_entity_types_connection.h | 19 + .../mocks/mock_environments_connection.h | 19 + .../mocks/mock_fulfillments_connection.h | 19 + .../mocks/mock_intents_connection.h | 19 + .../mocks/mock_knowledge_bases_connection.h | 19 + .../mocks/mock_participants_connection.h | 19 + .../mock_session_entity_types_connection.h | 19 + .../mocks/mock_sessions_connection.h | 19 + .../mocks/mock_versions_connection.h | 19 + .../dialogflow_es/participants_client.cc | 56 ++ .../cloud/dialogflow_es/participants_client.h | 295 +++++++++++ .../dialogflow_es/participants_connection.cc | 31 ++ .../dialogflow_es/participants_connection.h | 15 + ...ticipants_connection_idempotency_policy.cc | 25 + ...rticipants_connection_idempotency_policy.h | 17 + .../session_entity_types_client.cc | 60 +++ .../session_entity_types_client.h | 296 +++++++++++ .../session_entity_types_connection.cc | 33 ++ .../session_entity_types_connection.h | 15 + ...ity_types_connection_idempotency_policy.cc | 25 + ...tity_types_connection_idempotency_policy.h | 17 + google/cloud/dialogflow_es/sessions_client.cc | 54 ++ google/cloud/dialogflow_es/sessions_client.h | 296 +++++++++++ .../dialogflow_es/sessions_connection.cc | 31 ++ .../cloud/dialogflow_es/sessions_connection.h | 16 + .../sessions_connection_idempotency_policy.cc | 25 + .../sessions_connection_idempotency_policy.h | 17 + google/cloud/dialogflow_es/versions_client.cc | 54 ++ google/cloud/dialogflow_es/versions_client.h | 296 +++++++++++ .../dialogflow_es/versions_connection.cc | 30 ++ .../cloud/dialogflow_es/versions_connection.h | 15 + .../versions_connection_idempotency_policy.cc | 25 + .../versions_connection_idempotency_policy.h | 17 + google/cloud/discoveryengine/BUILD.bazel | 2 + .../discoveryengine/v1/completion_client.cc | 46 ++ .../discoveryengine/v1/completion_client.h | 225 ++++++++ .../v1/completion_connection.cc | 20 + .../v1/completion_connection.h | 10 + ...ompletion_connection_idempotency_policy.cc | 15 + ...completion_connection_idempotency_policy.h | 10 + .../discoveryengine/v1/control_client.cc | 45 ++ .../cloud/discoveryengine/v1/control_client.h | 225 ++++++++ .../discoveryengine/v1/control_connection.cc | 18 + .../discoveryengine/v1/control_connection.h | 9 + .../control_connection_idempotency_policy.cc | 15 + .../control_connection_idempotency_policy.h | 10 + .../v1/conversational_search_client.cc | 48 ++ .../v1/conversational_search_client.h | 225 ++++++++ .../v1/conversational_search_connection.cc | 19 + .../v1/conversational_search_connection.h | 9 + ...al_search_connection_idempotency_policy.cc | 18 + ...nal_search_connection_idempotency_policy.h | 10 + .../discoveryengine/v1/data_store_client.cc | 46 ++ .../discoveryengine/v1/data_store_client.h | 225 ++++++++ .../v1/data_store_connection.cc | 19 + .../v1/data_store_connection.h | 9 + ...ata_store_connection_idempotency_policy.cc | 15 + ...data_store_connection_idempotency_policy.h | 10 + .../discoveryengine/v1/document_client.cc | 45 ++ .../discoveryengine/v1/document_client.h | 225 ++++++++ .../discoveryengine/v1/document_connection.cc | 19 + .../discoveryengine/v1/document_connection.h | 9 + .../document_connection_idempotency_policy.cc | 15 + .../document_connection_idempotency_policy.h | 10 + .../cloud/discoveryengine/v1/engine_client.cc | 43 ++ .../cloud/discoveryengine/v1/engine_client.h | 225 ++++++++ .../discoveryengine/v1/engine_connection.cc | 18 + .../discoveryengine/v1/engine_connection.h | 9 + .../engine_connection_idempotency_policy.cc | 15 + .../v1/engine_connection_idempotency_policy.h | 10 + .../v1/grounded_generation_client.cc | 48 ++ .../v1/grounded_generation_client.h | 225 ++++++++ .../v1/grounded_generation_connection.cc | 20 + .../v1/grounded_generation_connection.h | 10 + ...eneration_connection_idempotency_policy.cc | 17 + ...generation_connection_idempotency_policy.h | 10 + .../v1/internal/completion_auth_decorator.cc | 25 + .../v1/internal/completion_auth_decorator.h | 12 + .../v1/internal/completion_connection_impl.cc | 62 +++ .../v1/internal/completion_connection_impl.h | 10 + .../internal/completion_logging_decorator.cc | 34 ++ .../internal/completion_logging_decorator.h | 12 + .../internal/completion_metadata_decorator.cc | 26 + .../internal/completion_metadata_decorator.h | 12 + .../v1/internal/completion_stub.cc | 35 ++ .../v1/internal/completion_stub.h | 32 +- .../v1/internal/completion_stub_factory.cc | 5 +- .../internal/completion_tracing_connection.cc | 29 ++ .../internal/completion_tracing_connection.h | 9 + .../v1/internal/completion_tracing_stub.cc | 35 ++ .../v1/internal/completion_tracing_stub.h | 12 + .../v1/internal/control_auth_decorator.cc | 25 + .../v1/internal/control_auth_decorator.h | 12 + .../v1/internal/control_connection_impl.cc | 60 +++ .../v1/internal/control_connection_impl.h | 9 + .../v1/internal/control_logging_decorator.cc | 34 ++ .../v1/internal/control_logging_decorator.h | 12 + .../v1/internal/control_metadata_decorator.cc | 25 + .../v1/internal/control_metadata_decorator.h | 12 + .../v1/internal/control_stub.cc | 35 ++ .../v1/internal/control_stub.h | 34 +- .../v1/internal/control_stub_factory.cc | 6 +- .../v1/internal/control_tracing_connection.cc | 28 + .../v1/internal/control_tracing_connection.h | 9 + .../v1/internal/control_tracing_stub.cc | 35 ++ .../v1/internal/control_tracing_stub.h | 12 + .../conversational_search_auth_decorator.cc | 26 + .../conversational_search_auth_decorator.h | 12 + .../conversational_search_connection_impl.cc | 61 +++ .../conversational_search_connection_impl.h | 9 + ...conversational_search_logging_decorator.cc | 35 ++ .../conversational_search_logging_decorator.h | 12 + ...onversational_search_metadata_decorator.cc | 26 + ...conversational_search_metadata_decorator.h | 12 + .../v1/internal/conversational_search_stub.cc | 35 ++ .../v1/internal/conversational_search_stub.h | 34 +- .../conversational_search_stub_factory.cc | 5 +- ...onversational_search_tracing_connection.cc | 31 ++ ...conversational_search_tracing_connection.h | 9 + .../conversational_search_tracing_stub.cc | 38 ++ .../conversational_search_tracing_stub.h | 12 + .../v1/internal/data_store_auth_decorator.cc | 25 + .../v1/internal/data_store_auth_decorator.h | 12 + .../v1/internal/data_store_connection_impl.cc | 60 +++ .../v1/internal/data_store_connection_impl.h | 9 + .../internal/data_store_logging_decorator.cc | 34 ++ .../internal/data_store_logging_decorator.h | 12 + .../internal/data_store_metadata_decorator.cc | 25 + .../internal/data_store_metadata_decorator.h | 12 + .../v1/internal/data_store_stub.cc | 35 ++ .../v1/internal/data_store_stub.h | 32 +- .../v1/internal/data_store_stub_factory.cc | 5 +- .../internal/data_store_tracing_connection.cc | 28 + .../internal/data_store_tracing_connection.h | 9 + .../v1/internal/data_store_tracing_stub.cc | 35 ++ .../v1/internal/data_store_tracing_stub.h | 12 + .../v1/internal/document_auth_decorator.cc | 25 + .../v1/internal/document_auth_decorator.h | 12 + .../v1/internal/document_connection_impl.cc | 60 +++ .../v1/internal/document_connection_impl.h | 9 + .../v1/internal/document_logging_decorator.cc | 34 ++ .../v1/internal/document_logging_decorator.h | 12 + .../internal/document_metadata_decorator.cc | 25 + .../v1/internal/document_metadata_decorator.h | 12 + .../v1/internal/document_stub.cc | 35 ++ .../v1/internal/document_stub.h | 32 +- .../v1/internal/document_stub_factory.cc | 5 +- .../internal/document_tracing_connection.cc | 28 + .../v1/internal/document_tracing_connection.h | 9 + .../v1/internal/document_tracing_stub.cc | 35 ++ .../v1/internal/document_tracing_stub.h | 12 + .../v1/internal/engine_auth_decorator.cc | 25 + .../v1/internal/engine_auth_decorator.h | 12 + .../v1/internal/engine_connection_impl.cc | 60 +++ .../v1/internal/engine_connection_impl.h | 9 + .../v1/internal/engine_logging_decorator.cc | 34 ++ .../v1/internal/engine_logging_decorator.h | 12 + .../v1/internal/engine_metadata_decorator.cc | 25 + .../v1/internal/engine_metadata_decorator.h | 12 + .../v1/internal/engine_stub.cc | 34 ++ .../discoveryengine/v1/internal/engine_stub.h | 32 +- .../v1/internal/engine_stub_factory.cc | 5 +- .../v1/internal/engine_tracing_connection.cc | 28 + .../v1/internal/engine_tracing_connection.h | 9 + .../v1/internal/engine_tracing_stub.cc | 34 ++ .../v1/internal/engine_tracing_stub.h | 12 + .../grounded_generation_auth_decorator.cc | 26 + .../grounded_generation_auth_decorator.h | 12 + .../grounded_generation_connection_impl.cc | 62 +++ .../grounded_generation_connection_impl.h | 10 + .../grounded_generation_logging_decorator.cc | 35 ++ .../grounded_generation_logging_decorator.h | 12 + .../grounded_generation_metadata_decorator.cc | 26 + .../grounded_generation_metadata_decorator.h | 12 + .../v1/internal/grounded_generation_stub.cc | 35 ++ .../v1/internal/grounded_generation_stub.h | 34 +- .../grounded_generation_stub_factory.cc | 5 +- .../grounded_generation_tracing_connection.cc | 31 ++ .../grounded_generation_tracing_connection.h | 9 + .../grounded_generation_tracing_stub.cc | 38 ++ .../grounded_generation_tracing_stub.h | 12 + .../v1/internal/project_auth_decorator.cc | 25 + .../v1/internal/project_auth_decorator.h | 12 + .../v1/internal/project_connection_impl.cc | 61 +++ .../v1/internal/project_connection_impl.h | 10 + .../v1/internal/project_logging_decorator.cc | 34 ++ .../v1/internal/project_logging_decorator.h | 12 + .../v1/internal/project_metadata_decorator.cc | 25 + .../v1/internal/project_metadata_decorator.h | 12 + .../v1/internal/project_stub.cc | 35 ++ .../v1/internal/project_stub.h | 32 +- .../v1/internal/project_stub_factory.cc | 5 +- .../v1/internal/project_tracing_connection.cc | 29 ++ .../v1/internal/project_tracing_connection.h | 9 + .../v1/internal/project_tracing_stub.cc | 35 ++ .../v1/internal/project_tracing_stub.h | 12 + .../v1/internal/rank_auth_decorator.cc | 25 + .../v1/internal/rank_auth_decorator.h | 12 + .../v1/internal/rank_connection_impl.cc | 61 +++ .../v1/internal/rank_connection_impl.h | 10 + .../v1/internal/rank_logging_decorator.cc | 34 ++ .../v1/internal/rank_logging_decorator.h | 12 + .../v1/internal/rank_metadata_decorator.cc | 25 + .../v1/internal/rank_metadata_decorator.h | 12 + .../discoveryengine/v1/internal/rank_stub.cc | 34 ++ .../discoveryengine/v1/internal/rank_stub.h | 34 +- .../v1/internal/rank_stub_factory.cc | 6 +- .../v1/internal/rank_tracing_connection.cc | 29 ++ .../v1/internal/rank_tracing_connection.h | 9 + .../v1/internal/rank_tracing_stub.cc | 34 ++ .../v1/internal/rank_tracing_stub.h | 12 + .../internal/recommendation_auth_decorator.cc | 26 + .../internal/recommendation_auth_decorator.h | 12 + .../recommendation_connection_impl.cc | 62 +++ .../internal/recommendation_connection_impl.h | 10 + .../recommendation_logging_decorator.cc | 35 ++ .../recommendation_logging_decorator.h | 12 + .../recommendation_metadata_decorator.cc | 26 + .../recommendation_metadata_decorator.h | 12 + .../v1/internal/recommendation_stub.cc | 35 ++ .../v1/internal/recommendation_stub.h | 34 +- .../internal/recommendation_stub_factory.cc | 5 +- .../recommendation_tracing_connection.cc | 29 ++ .../recommendation_tracing_connection.h | 9 + .../internal/recommendation_tracing_stub.cc | 37 ++ .../v1/internal/recommendation_tracing_stub.h | 12 + .../v1/internal/schema_auth_decorator.cc | 25 + .../v1/internal/schema_auth_decorator.h | 12 + .../v1/internal/schema_connection_impl.cc | 60 +++ .../v1/internal/schema_connection_impl.h | 9 + .../v1/internal/schema_logging_decorator.cc | 34 ++ .../v1/internal/schema_logging_decorator.h | 12 + .../v1/internal/schema_metadata_decorator.cc | 25 + .../v1/internal/schema_metadata_decorator.h | 12 + .../v1/internal/schema_stub.cc | 34 ++ .../discoveryengine/v1/internal/schema_stub.h | 32 +- .../v1/internal/schema_stub_factory.cc | 5 +- .../v1/internal/schema_tracing_connection.cc | 28 + .../v1/internal/schema_tracing_connection.h | 9 + .../v1/internal/schema_tracing_stub.cc | 34 ++ .../v1/internal/schema_tracing_stub.h | 12 + .../v1/internal/search_auth_decorator.cc | 25 + .../v1/internal/search_auth_decorator.h | 12 + .../v1/internal/search_connection_impl.cc | 60 +++ .../v1/internal/search_connection_impl.h | 9 + .../v1/internal/search_logging_decorator.cc | 34 ++ .../v1/internal/search_logging_decorator.h | 12 + .../v1/internal/search_metadata_decorator.cc | 25 + .../v1/internal/search_metadata_decorator.h | 12 + .../v1/internal/search_stub.cc | 34 ++ .../discoveryengine/v1/internal/search_stub.h | 34 +- .../v1/internal/search_stub_factory.cc | 6 +- .../v1/internal/search_tracing_connection.cc | 28 + .../v1/internal/search_tracing_connection.h | 9 + .../v1/internal/search_tracing_stub.cc | 34 ++ .../v1/internal/search_tracing_stub.h | 12 + .../site_search_engine_auth_decorator.cc | 26 + .../site_search_engine_auth_decorator.h | 12 + .../site_search_engine_connection_impl.cc | 61 +++ .../site_search_engine_connection_impl.h | 9 + .../site_search_engine_logging_decorator.cc | 35 ++ .../site_search_engine_logging_decorator.h | 12 + .../site_search_engine_metadata_decorator.cc | 26 + .../site_search_engine_metadata_decorator.h | 12 + .../v1/internal/site_search_engine_stub.cc | 35 ++ .../v1/internal/site_search_engine_stub.h | 32 +- .../site_search_engine_stub_factory.cc | 5 +- .../site_search_engine_tracing_connection.cc | 28 + .../site_search_engine_tracing_connection.h | 9 + .../site_search_engine_tracing_stub.cc | 38 ++ .../site_search_engine_tracing_stub.h | 12 + .../v1/internal/user_event_auth_decorator.cc | 25 + .../v1/internal/user_event_auth_decorator.h | 12 + .../v1/internal/user_event_connection_impl.cc | 61 +++ .../v1/internal/user_event_connection_impl.h | 10 + .../internal/user_event_logging_decorator.cc | 34 ++ .../internal/user_event_logging_decorator.h | 12 + .../internal/user_event_metadata_decorator.cc | 25 + .../internal/user_event_metadata_decorator.h | 12 + .../v1/internal/user_event_stub.cc | 35 ++ .../v1/internal/user_event_stub.h | 32 +- .../v1/internal/user_event_stub_factory.cc | 5 +- .../internal/user_event_tracing_connection.cc | 29 ++ .../internal/user_event_tracing_connection.h | 9 + .../v1/internal/user_event_tracing_stub.cc | 35 ++ .../v1/internal/user_event_tracing_stub.h | 12 + .../v1/mocks/mock_completion_connection.h | 11 + .../v1/mocks/mock_control_connection.h | 11 + .../mock_conversational_search_connection.h | 11 + .../v1/mocks/mock_data_store_connection.h | 11 + .../v1/mocks/mock_document_connection.h | 11 + .../v1/mocks/mock_engine_connection.h | 11 + .../mock_grounded_generation_connection.h | 11 + .../v1/mocks/mock_project_connection.h | 11 + .../v1/mocks/mock_rank_connection.h | 11 + .../v1/mocks/mock_recommendation_connection.h | 11 + .../v1/mocks/mock_schema_connection.h | 11 + .../v1/mocks/mock_search_connection.h | 11 + .../mock_site_search_engine_connection.h | 11 + .../v1/mocks/mock_user_event_connection.h | 11 + .../discoveryengine/v1/project_client.cc | 45 ++ .../cloud/discoveryengine/v1/project_client.h | 225 ++++++++ .../discoveryengine/v1/project_connection.cc | 19 + .../discoveryengine/v1/project_connection.h | 10 + .../project_connection_idempotency_policy.cc | 15 + .../project_connection_idempotency_policy.h | 10 + .../cloud/discoveryengine/v1/rank_client.cc | 43 ++ google/cloud/discoveryengine/v1/rank_client.h | 225 ++++++++ .../discoveryengine/v1/rank_connection.cc | 19 + .../discoveryengine/v1/rank_connection.h | 10 + .../v1/rank_connection_idempotency_policy.cc | 15 + .../v1/rank_connection_idempotency_policy.h | 10 + .../v1/recommendation_client.cc | 48 ++ .../v1/recommendation_client.h | 225 ++++++++ .../v1/recommendation_connection.cc | 20 + .../v1/recommendation_connection.h | 10 + ...mendation_connection_idempotency_policy.cc | 15 + ...mmendation_connection_idempotency_policy.h | 10 + .../cloud/discoveryengine/v1/schema_client.cc | 43 ++ .../cloud/discoveryengine/v1/schema_client.h | 225 ++++++++ .../discoveryengine/v1/schema_connection.cc | 18 + .../discoveryengine/v1/schema_connection.h | 9 + .../schema_connection_idempotency_policy.cc | 15 + .../v1/schema_connection_idempotency_policy.h | 10 + .../cloud/discoveryengine/v1/search_client.cc | 43 ++ .../cloud/discoveryengine/v1/search_client.h | 225 ++++++++ .../discoveryengine/v1/search_connection.cc | 18 + .../discoveryengine/v1/search_connection.h | 9 + .../search_connection_idempotency_policy.cc | 15 + .../v1/search_connection_idempotency_policy.h | 10 + .../v1/site_search_engine_client.cc | 48 ++ .../v1/site_search_engine_client.h | 225 ++++++++ .../v1/site_search_engine_connection.cc | 19 + .../v1/site_search_engine_connection.h | 9 + ...ch_engine_connection_idempotency_policy.cc | 15 + ...rch_engine_connection_idempotency_policy.h | 10 + .../discoveryengine/v1/user_event_client.cc | 46 ++ .../discoveryengine/v1/user_event_client.h | 225 ++++++++ .../v1/user_event_connection.cc | 20 + .../v1/user_event_connection.h | 10 + ...ser_event_connection_idempotency_policy.cc | 15 + ...user_event_connection_idempotency_policy.h | 10 + google/cloud/dlp/BUILD.bazel | 2 + google/cloud/documentai/BUILD.bazel | 2 + .../v1/document_processor_client.cc | 62 +++ .../documentai/v1/document_processor_client.h | 295 +++++++++++ .../v1/document_processor_connection.cc | 33 ++ .../v1/document_processor_connection.h | 15 + ...processor_connection_idempotency_policy.cc | 26 + ..._processor_connection_idempotency_policy.h | 17 + .../document_processor_auth_decorator.cc | 44 ++ .../document_processor_auth_decorator.h | 20 + .../document_processor_connection_impl.cc | 110 ++++ .../document_processor_connection_impl.h | 15 + .../document_processor_logging_decorator.cc | 59 +++ .../document_processor_logging_decorator.h | 20 + .../document_processor_metadata_decorator.cc | 44 ++ .../document_processor_metadata_decorator.h | 20 + .../v1/internal/document_processor_stub.cc | 59 +++ .../v1/internal/document_processor_stub.h | 55 +- .../document_processor_stub_factory.cc | 9 +- .../document_processor_tracing_connection.cc | 48 ++ .../document_processor_tracing_connection.h | 15 + .../document_processor_tracing_stub.cc | 59 +++ .../document_processor_tracing_stub.h | 20 + .../mock_document_processor_connection.h | 19 + google/cloud/edgecontainer/BUILD.bazel | 2 + .../edgecontainer/v1/edge_container_client.cc | 70 +++ .../edgecontainer/v1/edge_container_client.h | 350 +++++++++++++ .../v1/edge_container_connection.cc | 37 ++ .../v1/edge_container_connection.h | 18 + ...container_connection_idempotency_policy.cc | 30 ++ ..._container_connection_idempotency_policy.h | 20 + .../internal/edge_container_auth_decorator.cc | 50 ++ .../internal/edge_container_auth_decorator.h | 24 + .../edge_container_connection_impl.cc | 121 +++++ .../internal/edge_container_connection_impl.h | 18 + .../edge_container_logging_decorator.cc | 68 +++ .../edge_container_logging_decorator.h | 24 + .../edge_container_metadata_decorator.cc | 50 ++ .../edge_container_metadata_decorator.h | 24 + .../v1/internal/edge_container_stub.cc | 69 +++ .../v1/internal/edge_container_stub.h | 63 ++- .../internal/edge_container_stub_factory.cc | 9 +- .../edge_container_tracing_connection.cc | 56 ++ .../edge_container_tracing_connection.h | 18 + .../internal/edge_container_tracing_stub.cc | 69 +++ .../v1/internal/edge_container_tracing_stub.h | 24 + .../v1/mocks/mock_edge_container_connection.h | 23 + google/cloud/edgenetwork/BUILD.bazel | 2 + .../edgenetwork/v1/edge_network_client.cc | 69 +++ .../edgenetwork/v1/edge_network_client.h | 350 +++++++++++++ .../edgenetwork/v1/edge_network_connection.cc | 36 ++ .../edgenetwork/v1/edge_network_connection.h | 18 + ...e_network_connection_idempotency_policy.cc | 30 ++ ...ge_network_connection_idempotency_policy.h | 20 + .../internal/edge_network_auth_decorator.cc | 50 ++ .../v1/internal/edge_network_auth_decorator.h | 24 + .../internal/edge_network_connection_impl.cc | 121 +++++ .../internal/edge_network_connection_impl.h | 18 + .../edge_network_logging_decorator.cc | 68 +++ .../internal/edge_network_logging_decorator.h | 24 + .../edge_network_metadata_decorator.cc | 50 ++ .../edge_network_metadata_decorator.h | 24 + .../v1/internal/edge_network_stub.cc | 68 +++ .../v1/internal/edge_network_stub.h | 63 ++- .../v1/internal/edge_network_stub_factory.cc | 9 +- .../edge_network_tracing_connection.cc | 56 ++ .../edge_network_tracing_connection.h | 18 + .../v1/internal/edge_network_tracing_stub.cc | 68 +++ .../v1/internal/edge_network_tracing_stub.h | 24 + .../v1/mocks/mock_edge_network_connection.h | 23 + google/cloud/eventarc/BUILD.bazel | 2 + google/cloud/eventarc/v1/eventarc_client.cc | 86 +++ google/cloud/eventarc/v1/eventarc_client.h | 452 ++++++++++++++++ .../cloud/eventarc/v1/eventarc_connection.cc | 51 ++ .../cloud/eventarc/v1/eventarc_connection.h | 27 + .../eventarc_connection_idempotency_policy.cc | 46 ++ .../eventarc_connection_idempotency_policy.h | 30 ++ .../v1/internal/eventarc_auth_decorator.cc | 75 +++ .../v1/internal/eventarc_auth_decorator.h | 36 ++ .../v1/internal/eventarc_connection_impl.cc | 159 ++++++ .../v1/internal/eventarc_connection_impl.h | 27 + .../v1/internal/eventarc_logging_decorator.cc | 102 ++++ .../v1/internal/eventarc_logging_decorator.h | 36 ++ .../internal/eventarc_metadata_decorator.cc | 78 +++ .../v1/internal/eventarc_metadata_decorator.h | 36 ++ .../eventarc/v1/internal/eventarc_stub.cc | 103 ++++ .../eventarc/v1/internal/eventarc_stub.h | 92 +++- .../v1/internal/eventarc_stub_factory.cc | 11 +- .../internal/eventarc_tracing_connection.cc | 81 +++ .../v1/internal/eventarc_tracing_connection.h | 27 + .../v1/internal/eventarc_tracing_stub.cc | 102 ++++ .../v1/internal/eventarc_tracing_stub.h | 36 ++ .../v1/mocks/mock_eventarc_connection.h | 36 ++ google/cloud/filestore/BUILD.bazel | 2 + .../v1/cloud_filestore_manager_client.cc | 76 +++ .../v1/cloud_filestore_manager_client.h | 350 +++++++++++++ .../v1/cloud_filestore_manager_connection.cc | 38 ++ .../v1/cloud_filestore_manager_connection.h | 18 + ...e_manager_connection_idempotency_policy.cc | 30 ++ ...re_manager_connection_idempotency_policy.h | 20 + .../cloud_filestore_manager_auth_decorator.cc | 52 ++ .../cloud_filestore_manager_auth_decorator.h | 24 + ...cloud_filestore_manager_connection_impl.cc | 121 +++++ .../cloud_filestore_manager_connection_impl.h | 18 + ...oud_filestore_manager_logging_decorator.cc | 70 +++ ...loud_filestore_manager_logging_decorator.h | 24 + ...ud_filestore_manager_metadata_decorator.cc | 52 ++ ...oud_filestore_manager_metadata_decorator.h | 24 + .../internal/cloud_filestore_manager_stub.cc | 70 +++ .../internal/cloud_filestore_manager_stub.h | 63 ++- .../cloud_filestore_manager_stub_factory.cc | 9 +- ...ud_filestore_manager_tracing_connection.cc | 56 ++ ...oud_filestore_manager_tracing_connection.h | 18 + .../cloud_filestore_manager_tracing_stub.cc | 70 +++ .../cloud_filestore_manager_tracing_stub.h | 24 + .../mock_cloud_filestore_manager_connection.h | 23 + google/cloud/functions/BUILD.bazel | 2 + .../functions/v1/cloud_functions_client.cc | 41 ++ .../functions/v1/cloud_functions_client.h | 191 +++++++ .../v1/cloud_functions_connection.cc | 22 + .../functions/v1/cloud_functions_connection.h | 9 + ...functions_connection_idempotency_policy.cc | 15 + ..._functions_connection_idempotency_policy.h | 11 + .../cloud_functions_auth_decorator.cc | 27 + .../internal/cloud_functions_auth_decorator.h | 12 + .../cloud_functions_connection_impl.cc | 81 +++ .../cloud_functions_connection_impl.h | 9 + .../cloud_functions_logging_decorator.cc | 36 ++ .../cloud_functions_logging_decorator.h | 12 + .../cloud_functions_metadata_decorator.cc | 26 + .../cloud_functions_metadata_decorator.h | 12 + .../v1/internal/cloud_functions_stub.cc | 36 ++ .../v1/internal/cloud_functions_stub.h | 39 +- .../internal/cloud_functions_stub_factory.cc | 9 +- .../cloud_functions_tracing_connection.cc | 31 ++ .../cloud_functions_tracing_connection.h | 9 + .../internal/cloud_functions_tracing_stub.cc | 36 ++ .../internal/cloud_functions_tracing_stub.h | 12 + .../mocks/mock_cloud_functions_connection.h | 11 + google/cloud/functions/v2/function_client.cc | 57 ++ google/cloud/functions/v2/function_client.h | 293 +++++++++++ .../cloud/functions/v2/function_connection.cc | 38 ++ .../cloud/functions/v2/function_connection.h | 18 + .../function_connection_idempotency_policy.cc | 31 ++ .../function_connection_idempotency_policy.h | 21 + .../v2/internal/function_auth_decorator.cc | 51 ++ .../v2/internal/function_auth_decorator.h | 24 + .../v2/internal/function_connection_impl.cc | 121 +++++ .../v2/internal/function_connection_impl.h | 18 + .../v2/internal/function_logging_decorator.cc | 69 +++ .../v2/internal/function_logging_decorator.h | 24 + .../internal/function_metadata_decorator.cc | 54 ++ .../v2/internal/function_metadata_decorator.h | 24 + .../functions/v2/internal/function_stub.cc | 71 +++ .../functions/v2/internal/function_stub.h | 68 ++- .../v2/internal/function_stub_factory.cc | 11 +- .../internal/function_tracing_connection.cc | 58 +++ .../v2/internal/function_tracing_connection.h | 18 + .../v2/internal/function_tracing_stub.cc | 70 +++ .../v2/internal/function_tracing_stub.h | 24 + .../v2/mocks/mock_function_connection.h | 24 + google/cloud/gkebackup/BUILD.bazel | 2 + .../gkebackup/v1/backup_for_gke_client.cc | 89 ++++ .../gkebackup/v1/backup_for_gke_client.h | 452 ++++++++++++++++ .../gkebackup/v1/backup_for_gke_connection.cc | 52 ++ .../gkebackup/v1/backup_for_gke_connection.h | 27 + ...p_for_gke_connection_idempotency_policy.cc | 46 ++ ...up_for_gke_connection_idempotency_policy.h | 30 ++ .../internal/backup_for_gke_auth_decorator.cc | 75 +++ .../internal/backup_for_gke_auth_decorator.h | 36 ++ .../backup_for_gke_connection_impl.cc | 161 ++++++ .../internal/backup_for_gke_connection_impl.h | 27 + .../backup_for_gke_logging_decorator.cc | 102 ++++ .../backup_for_gke_logging_decorator.h | 36 ++ .../backup_for_gke_metadata_decorator.cc | 78 +++ .../backup_for_gke_metadata_decorator.h | 36 ++ .../v1/internal/backup_for_gke_stub.cc | 104 ++++ .../v1/internal/backup_for_gke_stub.h | 92 +++- .../internal/backup_for_gke_stub_factory.cc | 11 +- .../backup_for_gke_tracing_connection.cc | 81 +++ .../backup_for_gke_tracing_connection.h | 27 + .../internal/backup_for_gke_tracing_stub.cc | 103 ++++ .../v1/internal/backup_for_gke_tracing_stub.h | 36 ++ .../v1/mocks/mock_backup_for_gke_connection.h | 36 ++ .../v1/attached_clusters_client.cc | 60 +++ .../v1/attached_clusters_client.h | 280 ++++++++++ .../v1/attached_clusters_connection.cc | 24 + .../v1/attached_clusters_connection.h | 12 + ..._clusters_connection_idempotency_policy.cc | 20 + ...d_clusters_connection_idempotency_policy.h | 13 + .../gkemulticloud/v1/aws_clusters_client.cc | 57 ++ .../gkemulticloud/v1/aws_clusters_client.h | 280 ++++++++++ .../v1/aws_clusters_connection.cc | 23 + .../v1/aws_clusters_connection.h | 12 + ..._clusters_connection_idempotency_policy.cc | 20 + ...s_clusters_connection_idempotency_policy.h | 13 + .../gkemulticloud/v1/azure_clusters_client.cc | 57 ++ .../gkemulticloud/v1/azure_clusters_client.h | 280 ++++++++++ .../v1/azure_clusters_connection.cc | 23 + .../v1/azure_clusters_connection.h | 12 + ..._clusters_connection_idempotency_policy.cc | 20 + ...e_clusters_connection_idempotency_policy.h | 13 + .../attached_clusters_auth_decorator.cc | 33 ++ .../attached_clusters_auth_decorator.h | 16 + .../attached_clusters_connection_impl.cc | 73 +++ .../attached_clusters_connection_impl.h | 12 + .../attached_clusters_logging_decorator.cc | 45 ++ .../attached_clusters_logging_decorator.h | 16 + .../attached_clusters_metadata_decorator.cc | 33 ++ .../attached_clusters_metadata_decorator.h | 16 + .../v1/internal/attached_clusters_stub.cc | 46 ++ .../v1/internal/attached_clusters_stub.h | 40 +- .../attached_clusters_stub_factory.cc | 5 +- .../attached_clusters_tracing_connection.cc | 36 ++ .../attached_clusters_tracing_connection.h | 12 + .../attached_clusters_tracing_stub.cc | 46 ++ .../internal/attached_clusters_tracing_stub.h | 16 + .../internal/aws_clusters_auth_decorator.cc | 33 ++ .../v1/internal/aws_clusters_auth_decorator.h | 16 + .../internal/aws_clusters_connection_impl.cc | 73 +++ .../internal/aws_clusters_connection_impl.h | 12 + .../aws_clusters_logging_decorator.cc | 45 ++ .../internal/aws_clusters_logging_decorator.h | 16 + .../aws_clusters_metadata_decorator.cc | 33 ++ .../aws_clusters_metadata_decorator.h | 16 + .../v1/internal/aws_clusters_stub.cc | 45 ++ .../v1/internal/aws_clusters_stub.h | 40 +- .../v1/internal/aws_clusters_stub_factory.cc | 5 +- .../aws_clusters_tracing_connection.cc | 36 ++ .../aws_clusters_tracing_connection.h | 12 + .../v1/internal/aws_clusters_tracing_stub.cc | 45 ++ .../v1/internal/aws_clusters_tracing_stub.h | 16 + .../internal/azure_clusters_auth_decorator.cc | 33 ++ .../internal/azure_clusters_auth_decorator.h | 16 + .../azure_clusters_connection_impl.cc | 73 +++ .../internal/azure_clusters_connection_impl.h | 12 + .../azure_clusters_logging_decorator.cc | 45 ++ .../azure_clusters_logging_decorator.h | 16 + .../azure_clusters_metadata_decorator.cc | 33 ++ .../azure_clusters_metadata_decorator.h | 16 + .../v1/internal/azure_clusters_stub.cc | 45 ++ .../v1/internal/azure_clusters_stub.h | 40 +- .../internal/azure_clusters_stub_factory.cc | 5 +- .../azure_clusters_tracing_connection.cc | 36 ++ .../azure_clusters_tracing_connection.h | 12 + .../internal/azure_clusters_tracing_stub.cc | 45 ++ .../v1/internal/azure_clusters_tracing_stub.h | 16 + .../mocks/mock_attached_clusters_connection.h | 15 + .../v1/mocks/mock_aws_clusters_connection.h | 15 + .../v1/mocks/mock_azure_clusters_connection.h | 15 + .../v2/internal/policies_auth_decorator.cc | 8 + .../iam/v2/internal/policies_auth_decorator.h | 4 + .../v2/internal/policies_connection_impl.cc | 13 + .../v2/internal/policies_connection_impl.h | 3 + .../v2/internal/policies_logging_decorator.cc | 11 + .../v2/internal/policies_logging_decorator.h | 4 + .../internal/policies_metadata_decorator.cc | 8 + .../v2/internal/policies_metadata_decorator.h | 4 + google/cloud/iam/v2/internal/policies_stub.cc | 11 + google/cloud/iam/v2/internal/policies_stub.h | 16 +- .../iam/v2/internal/policies_stub_factory.cc | 5 +- .../internal/policies_tracing_connection.cc | 8 + .../v2/internal/policies_tracing_connection.h | 3 + .../iam/v2/internal/policies_tracing_stub.cc | 10 + .../iam/v2/internal/policies_tracing_stub.h | 4 + .../iam/v2/mocks/mock_policies_connection.h | 4 + google/cloud/iam/v2/policies_client.cc | 14 + google/cloud/iam/v2/policies_client.h | 60 +++ google/cloud/iam/v2/policies_connection.cc | 5 + google/cloud/iam/v2/policies_connection.h | 3 + .../policies_connection_idempotency_policy.cc | 5 + .../policies_connection_idempotency_policy.h | 4 + google/cloud/kms/BUILD.bazel | 2 + google/cloud/kms/v1/autokey_admin_client.cc | 46 ++ google/cloud/kms/v1/autokey_admin_client.h | 233 +++++++++ .../cloud/kms/v1/autokey_admin_connection.cc | 35 ++ .../cloud/kms/v1/autokey_admin_connection.h | 19 + ...key_admin_connection_idempotency_policy.cc | 31 ++ ...okey_admin_connection_idempotency_policy.h | 21 + google/cloud/kms/v1/autokey_client.cc | 45 ++ google/cloud/kms/v1/autokey_client.h | 233 +++++++++ google/cloud/kms/v1/autokey_connection.cc | 34 ++ google/cloud/kms/v1/autokey_connection.h | 19 + .../autokey_connection_idempotency_policy.cc | 31 ++ .../autokey_connection_idempotency_policy.h | 21 + google/cloud/kms/v1/ekm_client.cc | 45 ++ google/cloud/kms/v1/ekm_client.h | 233 +++++++++ google/cloud/kms/v1/ekm_connection.cc | 34 ++ google/cloud/kms/v1/ekm_connection.h | 18 + .../v1/ekm_connection_idempotency_policy.cc | 31 ++ .../v1/ekm_connection_idempotency_policy.h | 21 + .../internal/autokey_admin_auth_decorator.cc | 50 ++ .../internal/autokey_admin_auth_decorator.h | 24 + .../internal/autokey_admin_connection_impl.cc | 103 ++++ .../internal/autokey_admin_connection_impl.h | 19 + .../autokey_admin_logging_decorator.cc | 68 +++ .../autokey_admin_logging_decorator.h | 24 + .../autokey_admin_metadata_decorator.cc | 53 ++ .../autokey_admin_metadata_decorator.h | 24 + .../kms/v1/internal/autokey_admin_stub.cc | 70 +++ .../kms/v1/internal/autokey_admin_stub.h | 70 ++- .../v1/internal/autokey_admin_stub_factory.cc | 12 +- .../autokey_admin_tracing_connection.cc | 54 ++ .../autokey_admin_tracing_connection.h | 18 + .../v1/internal/autokey_admin_tracing_stub.cc | 69 +++ .../v1/internal/autokey_admin_tracing_stub.h | 24 + .../kms/v1/internal/autokey_auth_decorator.cc | 50 ++ .../kms/v1/internal/autokey_auth_decorator.h | 24 + .../v1/internal/autokey_connection_impl.cc | 101 ++++ .../kms/v1/internal/autokey_connection_impl.h | 19 + .../v1/internal/autokey_logging_decorator.cc | 68 +++ .../v1/internal/autokey_logging_decorator.h | 24 + .../v1/internal/autokey_metadata_decorator.cc | 53 ++ .../v1/internal/autokey_metadata_decorator.h | 24 + google/cloud/kms/v1/internal/autokey_stub.cc | 69 +++ google/cloud/kms/v1/internal/autokey_stub.h | 68 ++- .../kms/v1/internal/autokey_stub_factory.cc | 11 +- .../v1/internal/autokey_tracing_connection.cc | 49 ++ .../v1/internal/autokey_tracing_connection.h | 18 + .../kms/v1/internal/autokey_tracing_stub.cc | 68 +++ .../kms/v1/internal/autokey_tracing_stub.h | 24 + .../kms/v1/internal/ekm_auth_decorator.cc | 50 ++ .../kms/v1/internal/ekm_auth_decorator.h | 24 + .../kms/v1/internal/ekm_connection_impl.cc | 101 ++++ .../kms/v1/internal/ekm_connection_impl.h | 18 + .../kms/v1/internal/ekm_logging_decorator.cc | 68 +++ .../kms/v1/internal/ekm_logging_decorator.h | 24 + .../kms/v1/internal/ekm_metadata_decorator.cc | 53 ++ .../kms/v1/internal/ekm_metadata_decorator.h | 24 + google/cloud/kms/v1/internal/ekm_stub.cc | 69 +++ google/cloud/kms/v1/internal/ekm_stub.h | 70 ++- .../cloud/kms/v1/internal/ekm_stub_factory.cc | 12 +- .../kms/v1/internal/ekm_tracing_connection.cc | 49 ++ .../kms/v1/internal/ekm_tracing_connection.h | 18 + .../cloud/kms/v1/internal/ekm_tracing_stub.cc | 68 +++ .../cloud/kms/v1/internal/ekm_tracing_stub.h | 24 + .../internal/key_management_auth_decorator.cc | 51 ++ .../internal/key_management_auth_decorator.h | 24 + .../key_management_connection_impl.cc | 104 ++++ .../internal/key_management_connection_impl.h | 18 + .../key_management_logging_decorator.cc | 70 +++ .../key_management_logging_decorator.h | 24 + .../key_management_metadata_decorator.cc | 55 ++ .../key_management_metadata_decorator.h | 24 + .../kms/v1/internal/key_management_stub.cc | 71 +++ .../kms/v1/internal/key_management_stub.h | 70 ++- .../internal/key_management_stub_factory.cc | 11 +- .../key_management_tracing_connection.cc | 56 ++ .../key_management_tracing_connection.h | 18 + .../internal/key_management_tracing_stub.cc | 70 +++ .../v1/internal/key_management_tracing_stub.h | 24 + google/cloud/kms/v1/key_management_client.cc | 49 ++ google/cloud/kms/v1/key_management_client.h | 232 +++++++++ .../cloud/kms/v1/key_management_connection.cc | 36 ++ .../cloud/kms/v1/key_management_connection.h | 18 + ...anagement_connection_idempotency_policy.cc | 31 ++ ...management_connection_idempotency_policy.h | 21 + .../v1/mocks/mock_autokey_admin_connection.h | 25 + .../kms/v1/mocks/mock_autokey_connection.h | 25 + .../cloud/kms/v1/mocks/mock_ekm_connection.h | 25 + .../v1/mocks/mock_key_management_connection.h | 25 + .../logging/v2/config_service_v2_client.cc | 45 ++ .../logging/v2/config_service_v2_client.h | 225 ++++++++ .../v2/config_service_v2_connection.cc | 19 + .../logging/v2/config_service_v2_connection.h | 9 + ...ervice_v2_connection_idempotency_policy.cc | 15 + ...service_v2_connection_idempotency_policy.h | 10 + .../config_service_v2_auth_decorator.cc | 25 + .../config_service_v2_auth_decorator.h | 12 + .../config_service_v2_connection_impl.cc | 60 +++ .../config_service_v2_connection_impl.h | 9 + .../config_service_v2_logging_decorator.cc | 34 ++ .../config_service_v2_logging_decorator.h | 12 + .../config_service_v2_metadata_decorator.cc | 25 + .../config_service_v2_metadata_decorator.h | 12 + .../v2/internal/config_service_v2_stub.cc | 35 ++ .../v2/internal/config_service_v2_stub.h | 32 +- .../config_service_v2_stub_factory.cc | 5 +- .../config_service_v2_tracing_connection.cc | 28 + .../config_service_v2_tracing_connection.h | 9 + .../config_service_v2_tracing_stub.cc | 35 ++ .../internal/config_service_v2_tracing_stub.h | 12 + .../logging_service_v2_auth_decorator.cc | 25 + .../logging_service_v2_auth_decorator.h | 12 + .../logging_service_v2_connection_impl.cc | 60 +++ .../logging_service_v2_connection_impl.h | 9 + .../logging_service_v2_logging_decorator.cc | 34 ++ .../logging_service_v2_logging_decorator.h | 12 + .../logging_service_v2_metadata_decorator.cc | 25 + .../logging_service_v2_metadata_decorator.h | 12 + .../v2/internal/logging_service_v2_stub.cc | 35 ++ .../v2/internal/logging_service_v2_stub.h | 34 +- .../logging_service_v2_stub_factory.cc | 5 +- .../logging_service_v2_tracing_connection.cc | 28 + .../logging_service_v2_tracing_connection.h | 9 + .../logging_service_v2_tracing_stub.cc | 35 ++ .../logging_service_v2_tracing_stub.h | 12 + .../metrics_service_v2_auth_decorator.cc | 25 + .../metrics_service_v2_auth_decorator.h | 12 + .../metrics_service_v2_connection_impl.cc | 60 +++ .../metrics_service_v2_connection_impl.h | 9 + .../metrics_service_v2_logging_decorator.cc | 34 ++ .../metrics_service_v2_logging_decorator.h | 12 + .../metrics_service_v2_metadata_decorator.cc | 25 + .../metrics_service_v2_metadata_decorator.h | 12 + .../v2/internal/metrics_service_v2_stub.cc | 35 ++ .../v2/internal/metrics_service_v2_stub.h | 34 +- .../metrics_service_v2_stub_factory.cc | 5 +- .../metrics_service_v2_tracing_connection.cc | 28 + .../metrics_service_v2_tracing_connection.h | 9 + .../metrics_service_v2_tracing_stub.cc | 35 ++ .../metrics_service_v2_tracing_stub.h | 12 + .../logging/v2/logging_service_v2_client.cc | 46 ++ .../logging/v2/logging_service_v2_client.h | 225 ++++++++ .../v2/logging_service_v2_connection.cc | 19 + .../v2/logging_service_v2_connection.h | 9 + ...ervice_v2_connection_idempotency_policy.cc | 15 + ...service_v2_connection_idempotency_policy.h | 10 + .../logging/v2/metrics_service_v2_client.cc | 46 ++ .../logging/v2/metrics_service_v2_client.h | 225 ++++++++ .../v2/metrics_service_v2_connection.cc | 19 + .../v2/metrics_service_v2_connection.h | 9 + ...ervice_v2_connection_idempotency_policy.cc | 15 + ...service_v2_connection_idempotency_policy.h | 10 + .../mocks/mock_config_service_v2_connection.h | 11 + .../mock_logging_service_v2_connection.h | 11 + .../mock_metrics_service_v2_connection.h | 11 + google/cloud/managedkafka/BUILD.bazel | 2 + .../internal/managed_kafka_auth_decorator.cc | 50 ++ .../internal/managed_kafka_auth_decorator.h | 24 + .../internal/managed_kafka_connection_impl.cc | 121 +++++ .../internal/managed_kafka_connection_impl.h | 18 + .../managed_kafka_logging_decorator.cc | 68 +++ .../managed_kafka_logging_decorator.h | 24 + .../managed_kafka_metadata_decorator.cc | 50 ++ .../managed_kafka_metadata_decorator.h | 24 + .../v1/internal/managed_kafka_stub.cc | 69 +++ .../v1/internal/managed_kafka_stub.h | 63 ++- .../v1/internal/managed_kafka_stub_factory.cc | 9 +- .../managed_kafka_tracing_connection.cc | 56 ++ .../managed_kafka_tracing_connection.h | 18 + .../v1/internal/managed_kafka_tracing_stub.cc | 69 +++ .../v1/internal/managed_kafka_tracing_stub.h | 24 + .../managedkafka/v1/managed_kafka_client.cc | 70 +++ .../managedkafka/v1/managed_kafka_client.h | 350 +++++++++++++ .../v1/managed_kafka_connection.cc | 36 ++ .../v1/managed_kafka_connection.h | 18 + ...ged_kafka_connection_idempotency_policy.cc | 30 ++ ...aged_kafka_connection_idempotency_policy.h | 20 + .../v1/mocks/mock_managed_kafka_connection.h | 23 + google/cloud/memcache/BUILD.bazel | 2 + .../memcache/v1/cloud_memcache_client.cc | 70 +++ .../cloud/memcache/v1/cloud_memcache_client.h | 350 +++++++++++++ .../memcache/v1/cloud_memcache_connection.cc | 37 ++ .../memcache/v1/cloud_memcache_connection.h | 18 + ..._memcache_connection_idempotency_policy.cc | 30 ++ ...d_memcache_connection_idempotency_policy.h | 20 + .../internal/cloud_memcache_auth_decorator.cc | 50 ++ .../internal/cloud_memcache_auth_decorator.h | 24 + .../cloud_memcache_connection_impl.cc | 121 +++++ .../internal/cloud_memcache_connection_impl.h | 18 + .../cloud_memcache_logging_decorator.cc | 68 +++ .../cloud_memcache_logging_decorator.h | 24 + .../cloud_memcache_metadata_decorator.cc | 50 ++ .../cloud_memcache_metadata_decorator.h | 24 + .../v1/internal/cloud_memcache_stub.cc | 69 +++ .../v1/internal/cloud_memcache_stub.h | 63 ++- .../internal/cloud_memcache_stub_factory.cc | 9 +- .../cloud_memcache_tracing_connection.cc | 56 ++ .../cloud_memcache_tracing_connection.h | 18 + .../internal/cloud_memcache_tracing_stub.cc | 69 +++ .../v1/internal/cloud_memcache_tracing_stub.h | 24 + .../v1/mocks/mock_cloud_memcache_connection.h | 23 + google/cloud/metastore/BUILD.bazel | 2 + .../metastore/v1/dataproc_metastore_client.cc | 93 ++++ .../metastore/v1/dataproc_metastore_client.h | 452 ++++++++++++++++ .../v1/dataproc_metastore_connection.cc | 54 ++ .../v1/dataproc_metastore_connection.h | 27 + ...metastore_connection_idempotency_policy.cc | 46 ++ ..._metastore_connection_idempotency_policy.h | 30 ++ .../dataproc_metastore_federation_client.cc | 97 ++++ .../v1/dataproc_metastore_federation_client.h | 452 ++++++++++++++++ ...ataproc_metastore_federation_connection.cc | 56 ++ ...dataproc_metastore_federation_connection.h | 27 + ...ederation_connection_idempotency_policy.cc | 54 ++ ...federation_connection_idempotency_policy.h | 30 ++ .../dataproc_metastore_auth_decorator.cc | 75 +++ .../dataproc_metastore_auth_decorator.h | 36 ++ .../dataproc_metastore_connection_impl.cc | 161 ++++++ .../dataproc_metastore_connection_impl.h | 27 + ...roc_metastore_federation_auth_decorator.cc | 77 +++ ...proc_metastore_federation_auth_decorator.h | 36 ++ ...oc_metastore_federation_connection_impl.cc | 165 ++++++ ...roc_metastore_federation_connection_impl.h | 27 + ..._metastore_federation_logging_decorator.cc | 106 ++++ ...c_metastore_federation_logging_decorator.h | 36 ++ ...metastore_federation_metadata_decorator.cc | 82 +++ ..._metastore_federation_metadata_decorator.h | 36 ++ .../dataproc_metastore_federation_stub.cc | 107 ++++ .../dataproc_metastore_federation_stub.h | 92 +++- ...aproc_metastore_federation_stub_factory.cc | 11 +- ...metastore_federation_tracing_connection.cc | 84 +++ ..._metastore_federation_tracing_connection.h | 27 + ...aproc_metastore_federation_tracing_stub.cc | 110 ++++ ...taproc_metastore_federation_tracing_stub.h | 36 ++ .../dataproc_metastore_logging_decorator.cc | 103 ++++ .../dataproc_metastore_logging_decorator.h | 36 ++ .../dataproc_metastore_metadata_decorator.cc | 80 +++ .../dataproc_metastore_metadata_decorator.h | 36 ++ .../v1/internal/dataproc_metastore_stub.cc | 105 ++++ .../v1/internal/dataproc_metastore_stub.h | 92 +++- .../dataproc_metastore_stub_factory.cc | 11 +- .../dataproc_metastore_tracing_connection.cc | 83 +++ .../dataproc_metastore_tracing_connection.h | 27 + .../dataproc_metastore_tracing_stub.cc | 104 ++++ .../dataproc_metastore_tracing_stub.h | 36 ++ .../mock_dataproc_metastore_connection.h | 36 ++ ...dataproc_metastore_federation_connection.h | 36 ++ google/cloud/migrationcenter/BUILD.bazel | 2 + .../migration_center_auth_decorator.cc | 50 ++ .../migration_center_auth_decorator.h | 24 + .../migration_center_connection_impl.cc | 121 +++++ .../migration_center_connection_impl.h | 18 + .../migration_center_logging_decorator.cc | 68 +++ .../migration_center_logging_decorator.h | 24 + .../migration_center_metadata_decorator.cc | 51 ++ .../migration_center_metadata_decorator.h | 24 + .../v1/internal/migration_center_stub.cc | 70 +++ .../v1/internal/migration_center_stub.h | 63 ++- .../internal/migration_center_stub_factory.cc | 9 +- .../migration_center_tracing_connection.cc | 56 ++ .../migration_center_tracing_connection.h | 18 + .../internal/migration_center_tracing_stub.cc | 70 +++ .../internal/migration_center_tracing_stub.h | 24 + .../v1/migration_center_client.cc | 72 +++ .../v1/migration_center_client.h | 350 +++++++++++++ .../v1/migration_center_connection.cc | 38 ++ .../v1/migration_center_connection.h | 18 + ...on_center_connection_idempotency_policy.cc | 30 ++ ...ion_center_connection_idempotency_policy.h | 20 + .../mocks/mock_migration_center_connection.h | 23 + google/cloud/netapp/BUILD.bazel | 2 + .../v1/internal/net_app_auth_decorator.cc | 50 ++ .../v1/internal/net_app_auth_decorator.h | 24 + .../v1/internal/net_app_connection_impl.cc | 119 +++++ .../v1/internal/net_app_connection_impl.h | 18 + .../v1/internal/net_app_logging_decorator.cc | 68 +++ .../v1/internal/net_app_logging_decorator.h | 24 + .../v1/internal/net_app_metadata_decorator.cc | 50 ++ .../v1/internal/net_app_metadata_decorator.h | 24 + .../cloud/netapp/v1/internal/net_app_stub.cc | 68 +++ .../cloud/netapp/v1/internal/net_app_stub.h | 63 ++- .../v1/internal/net_app_stub_factory.cc | 9 +- .../v1/internal/net_app_tracing_connection.cc | 51 ++ .../v1/internal/net_app_tracing_connection.h | 18 + .../v1/internal/net_app_tracing_stub.cc | 68 +++ .../netapp/v1/internal/net_app_tracing_stub.h | 24 + .../netapp/v1/mocks/mock_net_app_connection.h | 23 + google/cloud/netapp/v1/net_app_client.cc | 67 +++ google/cloud/netapp/v1/net_app_client.h | 350 +++++++++++++ google/cloud/netapp/v1/net_app_connection.cc | 34 ++ google/cloud/netapp/v1/net_app_connection.h | 18 + .../net_app_connection_idempotency_policy.cc | 30 ++ .../net_app_connection_idempotency_policy.h | 20 + google/cloud/networkconnectivity/BUILD.bazel | 2 + .../networkconnectivity/v1/hub_client.cc | 88 ++++ .../cloud/networkconnectivity/v1/hub_client.h | 452 ++++++++++++++++ .../networkconnectivity/v1/hub_connection.cc | 52 ++ .../networkconnectivity/v1/hub_connection.h | 27 + .../v1/hub_connection_idempotency_policy.cc | 46 ++ .../v1/hub_connection_idempotency_policy.h | 30 ++ .../v1/internal/hub_auth_decorator.cc | 75 +++ .../v1/internal/hub_auth_decorator.h | 36 ++ .../v1/internal/hub_connection_impl.cc | 160 ++++++ .../v1/internal/hub_connection_impl.h | 27 + .../v1/internal/hub_logging_decorator.cc | 102 ++++ .../v1/internal/hub_logging_decorator.h | 36 ++ .../v1/internal/hub_metadata_decorator.cc | 78 +++ .../v1/internal/hub_metadata_decorator.h | 36 ++ .../v1/internal/hub_stub.cc | 103 ++++ .../v1/internal/hub_stub.h | 92 +++- .../v1/internal/hub_stub_factory.cc | 11 +- .../v1/internal/hub_tracing_connection.cc | 81 +++ .../v1/internal/hub_tracing_connection.h | 27 + .../v1/internal/hub_tracing_stub.cc | 102 ++++ .../v1/internal/hub_tracing_stub.h | 36 ++ .../policy_based_routing_auth_decorator.cc | 77 +++ .../policy_based_routing_auth_decorator.h | 36 ++ .../policy_based_routing_connection_impl.cc | 165 ++++++ .../policy_based_routing_connection_impl.h | 27 + .../policy_based_routing_logging_decorator.cc | 106 ++++ .../policy_based_routing_logging_decorator.h | 36 ++ ...policy_based_routing_metadata_decorator.cc | 82 +++ .../policy_based_routing_metadata_decorator.h | 36 ++ .../v1/internal/policy_based_routing_stub.cc | 107 ++++ .../v1/internal/policy_based_routing_stub.h | 92 +++- .../policy_based_routing_stub_factory.cc | 11 +- ...policy_based_routing_tracing_connection.cc | 92 ++++ .../policy_based_routing_tracing_connection.h | 27 + .../policy_based_routing_tracing_stub.cc | 115 ++++ .../policy_based_routing_tracing_stub.h | 36 ++ .../v1/mocks/mock_hub_connection.h | 36 ++ .../mock_policy_based_routing_connection.h | 36 ++ .../v1/policy_based_routing_client.cc | 95 ++++ .../v1/policy_based_routing_client.h | 452 ++++++++++++++++ .../v1/policy_based_routing_connection.cc | 56 ++ .../v1/policy_based_routing_connection.h | 27 + ...d_routing_connection_idempotency_policy.cc | 50 ++ ...ed_routing_connection_idempotency_policy.h | 30 ++ google/cloud/networkmanagement/BUILD.bazel | 2 + .../internal/reachability_auth_decorator.cc | 76 +++ .../v1/internal/reachability_auth_decorator.h | 36 ++ .../internal/reachability_connection_impl.cc | 165 ++++++ .../internal/reachability_connection_impl.h | 27 + .../reachability_logging_decorator.cc | 104 ++++ .../internal/reachability_logging_decorator.h | 36 ++ .../reachability_metadata_decorator.cc | 80 +++ .../reachability_metadata_decorator.h | 36 ++ .../v1/internal/reachability_stub.cc | 105 ++++ .../v1/internal/reachability_stub.h | 92 +++- .../v1/internal/reachability_stub_factory.cc | 11 +- .../reachability_tracing_connection.cc | 84 +++ .../reachability_tracing_connection.h | 27 + .../v1/internal/reachability_tracing_stub.cc | 108 ++++ .../v1/internal/reachability_tracing_stub.h | 36 ++ .../v1/mocks/mock_reachability_connection.h | 36 ++ .../v1/reachability_client.cc | 94 ++++ .../v1/reachability_client.h | 452 ++++++++++++++++ .../v1/reachability_connection.cc | 54 ++ .../v1/reachability_connection.h | 27 + ...chability_connection_idempotency_policy.cc | 46 ++ ...achability_connection_idempotency_policy.h | 30 ++ google/cloud/networksecurity/BUILD.bazel | 2 + .../network_security_auth_decorator.cc | 75 +++ .../network_security_auth_decorator.h | 36 ++ .../network_security_connection_impl.cc | 161 ++++++ .../network_security_connection_impl.h | 27 + .../network_security_logging_decorator.cc | 102 ++++ .../network_security_logging_decorator.h | 36 ++ .../network_security_metadata_decorator.cc | 79 +++ .../network_security_metadata_decorator.h | 36 ++ .../v1/internal/network_security_stub.cc | 105 ++++ .../v1/internal/network_security_stub.h | 92 +++- .../internal/network_security_stub_factory.cc | 11 +- .../network_security_tracing_connection.cc | 83 +++ .../network_security_tracing_connection.h | 27 + .../internal/network_security_tracing_stub.cc | 104 ++++ .../internal/network_security_tracing_stub.h | 36 ++ .../mocks/mock_network_security_connection.h | 36 ++ .../v1/network_security_client.cc | 91 ++++ .../v1/network_security_client.h | 452 ++++++++++++++++ .../v1/network_security_connection.cc | 54 ++ .../v1/network_security_connection.h | 27 + ..._security_connection_idempotency_policy.cc | 46 ++ ...k_security_connection_idempotency_policy.h | 30 ++ google/cloud/networkservices/BUILD.bazel | 2 + google/cloud/networkservices/v1/dep_client.cc | 88 ++++ google/cloud/networkservices/v1/dep_client.h | 452 ++++++++++++++++ .../networkservices/v1/dep_connection.cc | 52 ++ .../cloud/networkservices/v1/dep_connection.h | 27 + .../v1/dep_connection_idempotency_policy.cc | 46 ++ .../v1/dep_connection_idempotency_policy.h | 30 ++ .../v1/internal/dep_auth_decorator.cc | 75 +++ .../v1/internal/dep_auth_decorator.h | 36 ++ .../v1/internal/dep_connection_impl.cc | 160 ++++++ .../v1/internal/dep_connection_impl.h | 27 + .../v1/internal/dep_logging_decorator.cc | 102 ++++ .../v1/internal/dep_logging_decorator.h | 36 ++ .../v1/internal/dep_metadata_decorator.cc | 78 +++ .../v1/internal/dep_metadata_decorator.h | 36 ++ .../networkservices/v1/internal/dep_stub.cc | 103 ++++ .../networkservices/v1/internal/dep_stub.h | 92 +++- .../v1/internal/dep_stub_factory.cc | 11 +- .../v1/internal/dep_tracing_connection.cc | 81 +++ .../v1/internal/dep_tracing_connection.h | 27 + .../v1/internal/dep_tracing_stub.cc | 102 ++++ .../v1/internal/dep_tracing_stub.h | 36 ++ .../network_services_auth_decorator.cc | 75 +++ .../network_services_auth_decorator.h | 36 ++ .../network_services_connection_impl.cc | 161 ++++++ .../network_services_connection_impl.h | 27 + .../network_services_logging_decorator.cc | 102 ++++ .../network_services_logging_decorator.h | 36 ++ .../network_services_metadata_decorator.cc | 79 +++ .../network_services_metadata_decorator.h | 36 ++ .../v1/internal/network_services_stub.cc | 105 ++++ .../v1/internal/network_services_stub.h | 92 +++- .../internal/network_services_stub_factory.cc | 11 +- .../network_services_tracing_connection.cc | 83 +++ .../network_services_tracing_connection.h | 27 + .../internal/network_services_tracing_stub.cc | 104 ++++ .../internal/network_services_tracing_stub.h | 36 ++ .../v1/mocks/mock_dep_connection.h | 36 ++ .../mocks/mock_network_services_connection.h | 36 ++ .../v1/network_services_client.cc | 91 ++++ .../v1/network_services_client.h | 452 ++++++++++++++++ .../v1/network_services_connection.cc | 54 ++ .../v1/network_services_connection.h | 27 + ..._services_connection_idempotency_policy.cc | 46 ++ ...k_services_connection_idempotency_policy.h | 30 ++ google/cloud/notebooks/BUILD.bazel | 2 + .../managed_notebook_auth_decorator.cc | 77 +++ .../managed_notebook_auth_decorator.h | 36 ++ .../managed_notebook_connection_impl.cc | 163 ++++++ .../managed_notebook_connection_impl.h | 27 + .../managed_notebook_logging_decorator.cc | 104 ++++ .../managed_notebook_logging_decorator.h | 36 ++ .../managed_notebook_metadata_decorator.cc | 80 +++ .../managed_notebook_metadata_decorator.h | 36 ++ .../v1/internal/managed_notebook_stub.cc | 107 ++++ .../v1/internal/managed_notebook_stub.h | 92 +++- .../internal/managed_notebook_stub_factory.cc | 11 +- .../managed_notebook_tracing_connection.cc | 83 +++ .../managed_notebook_tracing_connection.h | 27 + .../internal/managed_notebook_tracing_stub.cc | 106 ++++ .../internal/managed_notebook_tracing_stub.h | 36 ++ .../v1/internal/notebook_auth_decorator.cc | 75 +++ .../v1/internal/notebook_auth_decorator.h | 36 ++ .../v1/internal/notebook_connection_impl.cc | 161 ++++++ .../v1/internal/notebook_connection_impl.h | 27 + .../v1/internal/notebook_logging_decorator.cc | 102 ++++ .../v1/internal/notebook_logging_decorator.h | 36 ++ .../internal/notebook_metadata_decorator.cc | 79 +++ .../v1/internal/notebook_metadata_decorator.h | 36 ++ .../notebooks/v1/internal/notebook_stub.cc | 105 ++++ .../notebooks/v1/internal/notebook_stub.h | 92 +++- .../v1/internal/notebook_stub_factory.cc | 11 +- .../internal/notebook_tracing_connection.cc | 83 +++ .../v1/internal/notebook_tracing_connection.h | 27 + .../v1/internal/notebook_tracing_stub.cc | 104 ++++ .../v1/internal/notebook_tracing_stub.h | 36 ++ .../notebooks/v1/managed_notebook_client.cc | 95 ++++ .../notebooks/v1/managed_notebook_client.h | 453 ++++++++++++++++ .../v1/managed_notebook_connection.cc | 56 ++ .../v1/managed_notebook_connection.h | 27 + ..._notebook_connection_idempotency_policy.cc | 47 ++ ...d_notebook_connection_idempotency_policy.h | 30 ++ .../mocks/mock_managed_notebook_connection.h | 36 ++ .../v1/mocks/mock_notebook_connection.h | 36 ++ google/cloud/notebooks/v1/notebook_client.cc | 91 ++++ google/cloud/notebooks/v1/notebook_client.h | 452 ++++++++++++++++ .../cloud/notebooks/v1/notebook_connection.cc | 54 ++ .../cloud/notebooks/v1/notebook_connection.h | 27 + .../notebook_connection_idempotency_policy.cc | 46 ++ .../notebook_connection_idempotency_policy.h | 30 ++ .../v2/internal/notebook_auth_decorator.cc | 75 +++ .../v2/internal/notebook_auth_decorator.h | 36 ++ .../v2/internal/notebook_connection_impl.cc | 161 ++++++ .../v2/internal/notebook_connection_impl.h | 27 + .../v2/internal/notebook_logging_decorator.cc | 102 ++++ .../v2/internal/notebook_logging_decorator.h | 36 ++ .../internal/notebook_metadata_decorator.cc | 79 +++ .../v2/internal/notebook_metadata_decorator.h | 36 ++ .../notebooks/v2/internal/notebook_stub.cc | 105 ++++ .../notebooks/v2/internal/notebook_stub.h | 92 +++- .../v2/internal/notebook_stub_factory.cc | 11 +- .../internal/notebook_tracing_connection.cc | 83 +++ .../v2/internal/notebook_tracing_connection.h | 27 + .../v2/internal/notebook_tracing_stub.cc | 104 ++++ .../v2/internal/notebook_tracing_stub.h | 36 ++ .../v2/mocks/mock_notebook_connection.h | 36 ++ google/cloud/notebooks/v2/notebook_client.cc | 91 ++++ google/cloud/notebooks/v2/notebook_client.h | 452 ++++++++++++++++ .../cloud/notebooks/v2/notebook_connection.cc | 54 ++ .../cloud/notebooks/v2/notebook_connection.h | 27 + .../notebook_connection_idempotency_policy.cc | 46 ++ .../notebook_connection_idempotency_policy.h | 30 ++ .../optimization/v1/fleet_routing_client.cc | 14 + .../optimization/v1/fleet_routing_client.h | 60 +++ .../v1/fleet_routing_connection.cc | 5 + .../v1/fleet_routing_connection.h | 3 + ...t_routing_connection_idempotency_policy.cc | 5 + ...et_routing_connection_idempotency_policy.h | 4 + .../internal/fleet_routing_auth_decorator.cc | 8 + .../internal/fleet_routing_auth_decorator.h | 4 + .../internal/fleet_routing_connection_impl.cc | 14 + .../internal/fleet_routing_connection_impl.h | 3 + .../fleet_routing_logging_decorator.cc | 11 + .../fleet_routing_logging_decorator.h | 4 + .../fleet_routing_metadata_decorator.cc | 8 + .../fleet_routing_metadata_decorator.h | 4 + .../v1/internal/fleet_routing_stub.cc | 11 + .../v1/internal/fleet_routing_stub.h | 16 +- .../v1/internal/fleet_routing_stub_factory.cc | 5 +- .../fleet_routing_tracing_connection.cc | 9 + .../fleet_routing_tracing_connection.h | 3 + .../v1/internal/fleet_routing_tracing_stub.cc | 11 + .../v1/internal/fleet_routing_tracing_stub.h | 4 + .../v1/mocks/mock_fleet_routing_connection.h | 4 + .../v1/internal/simulator_auth_decorator.cc | 17 + .../v1/internal/simulator_auth_decorator.h | 8 + .../v1/internal/simulator_connection_impl.cc | 46 ++ .../v1/internal/simulator_connection_impl.h | 6 + .../internal/simulator_logging_decorator.cc | 23 + .../v1/internal/simulator_logging_decorator.h | 8 + .../internal/simulator_metadata_decorator.cc | 17 + .../internal/simulator_metadata_decorator.h | 8 + .../v1/internal/simulator_stub.cc | 23 + .../v1/internal/simulator_stub.h | 24 +- .../v1/internal/simulator_stub_factory.cc | 5 +- .../internal/simulator_tracing_connection.cc | 20 + .../internal/simulator_tracing_connection.h | 6 + .../v1/internal/simulator_tracing_stub.cc | 23 + .../v1/internal/simulator_tracing_stub.h | 8 + .../v1/mocks/mock_simulator_connection.h | 7 + .../policysimulator/v1/simulator_client.cc | 29 ++ .../policysimulator/v1/simulator_client.h | 152 ++++++ .../v1/simulator_connection.cc | 12 + .../policysimulator/v1/simulator_connection.h | 6 + ...simulator_connection_idempotency_policy.cc | 10 + .../simulator_connection_idempotency_policy.h | 7 + google/cloud/privateca/BUILD.bazel | 2 + .../v1/certificate_authority_client.cc | 97 ++++ .../v1/certificate_authority_client.h | 452 ++++++++++++++++ .../v1/certificate_authority_connection.cc | 56 ++ .../v1/certificate_authority_connection.h | 27 + ...authority_connection_idempotency_policy.cc | 54 ++ ..._authority_connection_idempotency_policy.h | 30 ++ .../certificate_authority_auth_decorator.cc | 77 +++ .../certificate_authority_auth_decorator.h | 36 ++ .../certificate_authority_connection_impl.cc | 165 ++++++ .../certificate_authority_connection_impl.h | 27 + ...certificate_authority_logging_decorator.cc | 106 ++++ .../certificate_authority_logging_decorator.h | 36 ++ ...ertificate_authority_metadata_decorator.cc | 82 +++ ...certificate_authority_metadata_decorator.h | 36 ++ .../v1/internal/certificate_authority_stub.cc | 107 ++++ .../v1/internal/certificate_authority_stub.h | 92 +++- .../certificate_authority_stub_factory.cc | 11 +- ...ertificate_authority_tracing_connection.cc | 84 +++ ...certificate_authority_tracing_connection.h | 27 + .../certificate_authority_tracing_stub.cc | 115 ++++ .../certificate_authority_tracing_stub.h | 36 ++ .../mock_certificate_authority_connection.h | 36 ++ .../cloud/privilegedaccessmanager/BUILD.bazel | 2 + ...rivileged_access_manager_auth_decorator.cc | 44 ++ ...privileged_access_manager_auth_decorator.h | 20 + ...ivileged_access_manager_connection_impl.cc | 110 ++++ ...rivileged_access_manager_connection_impl.h | 15 + ...ileged_access_manager_logging_decorator.cc | 59 +++ ...vileged_access_manager_logging_decorator.h | 20 + ...leged_access_manager_metadata_decorator.cc | 44 ++ ...ileged_access_manager_metadata_decorator.h | 20 + .../privileged_access_manager_stub.cc | 59 +++ .../internal/privileged_access_manager_stub.h | 55 +- .../privileged_access_manager_stub_factory.cc | 9 +- ...leged_access_manager_tracing_connection.cc | 53 ++ ...ileged_access_manager_tracing_connection.h | 15 + .../privileged_access_manager_tracing_stub.cc | 64 +++ .../privileged_access_manager_tracing_stub.h | 20 + ...ock_privileged_access_manager_connection.h | 19 + .../v1/privileged_access_manager_client.cc | 62 +++ .../v1/privileged_access_manager_client.h | 278 ++++++++++ .../privileged_access_manager_connection.cc | 33 ++ .../v1/privileged_access_manager_connection.h | 15 + ...s_manager_connection_idempotency_policy.cc | 25 + ...ss_manager_connection_idempotency_policy.h | 17 + google/cloud/pubsub/BUILD.bazel | 2 + google/cloud/pubsublite/admin_client.cc | 57 ++ google/cloud/pubsublite/admin_client.h | 280 ++++++++++ google/cloud/pubsublite/admin_connection.cc | 23 + google/cloud/pubsublite/admin_connection.h | 12 + .../admin_connection_idempotency_policy.cc | 20 + .../admin_connection_idempotency_policy.h | 13 + .../internal/admin_auth_decorator.cc | 33 ++ .../internal/admin_auth_decorator.h | 16 + .../internal/admin_connection_impl.cc | 73 +++ .../internal/admin_connection_impl.h | 12 + .../internal/admin_logging_decorator.cc | 45 ++ .../internal/admin_logging_decorator.h | 16 + .../internal/admin_metadata_decorator.cc | 33 ++ .../internal/admin_metadata_decorator.h | 16 + .../cloud/pubsublite/internal/admin_stub.cc | 45 ++ google/cloud/pubsublite/internal/admin_stub.h | 40 +- .../pubsublite/internal/admin_stub_factory.cc | 5 +- .../internal/admin_tracing_connection.cc | 36 ++ .../internal/admin_tracing_connection.h | 12 + .../pubsublite/internal/admin_tracing_stub.cc | 45 ++ .../pubsublite/internal/admin_tracing_stub.h | 16 + .../internal/cursor_auth_decorator.cc | 33 ++ .../internal/cursor_auth_decorator.h | 16 + .../internal/cursor_logging_decorator.cc | 45 ++ .../internal/cursor_logging_decorator.h | 16 + .../internal/cursor_metadata_decorator.cc | 33 ++ .../internal/cursor_metadata_decorator.h | 16 + .../cloud/pubsublite/internal/cursor_stub.cc | 45 ++ .../cloud/pubsublite/internal/cursor_stub.h | 42 +- .../internal/cursor_stub_factory.cc | 6 +- .../internal/cursor_tracing_stub.cc | 45 ++ .../pubsublite/internal/cursor_tracing_stub.h | 16 + .../partition_assignment_auth_decorator.cc | 34 ++ .../partition_assignment_auth_decorator.h | 16 + .../partition_assignment_logging_decorator.cc | 46 ++ .../partition_assignment_logging_decorator.h | 16 + ...partition_assignment_metadata_decorator.cc | 34 ++ .../partition_assignment_metadata_decorator.h | 16 + .../internal/partition_assignment_stub.cc | 46 ++ .../internal/partition_assignment_stub.h | 42 +- .../partition_assignment_stub_factory.cc | 5 +- .../partition_assignment_tracing_stub.cc | 49 ++ .../partition_assignment_tracing_stub.h | 16 + .../internal/publisher_auth_decorator.cc | 33 ++ .../internal/publisher_auth_decorator.h | 16 + .../internal/publisher_logging_decorator.cc | 45 ++ .../internal/publisher_logging_decorator.h | 16 + .../internal/publisher_metadata_decorator.cc | 33 ++ .../internal/publisher_metadata_decorator.h | 16 + .../pubsublite/internal/publisher_stub.cc | 46 ++ .../pubsublite/internal/publisher_stub.h | 42 +- .../internal/publisher_stub_factory.cc | 5 +- .../internal/publisher_tracing_stub.cc | 46 ++ .../internal/publisher_tracing_stub.h | 16 + .../internal/subscriber_auth_decorator.cc | 33 ++ .../internal/subscriber_auth_decorator.h | 16 + .../internal/subscriber_logging_decorator.cc | 45 ++ .../internal/subscriber_logging_decorator.h | 16 + .../internal/subscriber_metadata_decorator.cc | 34 ++ .../internal/subscriber_metadata_decorator.h | 16 + .../pubsublite/internal/subscriber_stub.cc | 46 ++ .../pubsublite/internal/subscriber_stub.h | 42 +- .../internal/subscriber_stub_factory.cc | 5 +- .../internal/subscriber_tracing_stub.cc | 46 ++ .../internal/subscriber_tracing_stub.h | 16 + .../internal/topic_stats_auth_decorator.cc | 33 ++ .../internal/topic_stats_auth_decorator.h | 16 + .../internal/topic_stats_connection_impl.cc | 74 +++ .../internal/topic_stats_connection_impl.h | 13 + .../internal/topic_stats_logging_decorator.cc | 45 ++ .../internal/topic_stats_logging_decorator.h | 16 + .../topic_stats_metadata_decorator.cc | 34 ++ .../internal/topic_stats_metadata_decorator.h | 16 + .../pubsublite/internal/topic_stats_stub.cc | 46 ++ .../pubsublite/internal/topic_stats_stub.h | 42 +- .../internal/topic_stats_stub_factory.cc | 5 +- .../topic_stats_tracing_connection.cc | 37 ++ .../internal/topic_stats_tracing_connection.h | 12 + .../internal/topic_stats_tracing_stub.cc | 46 ++ .../internal/topic_stats_tracing_stub.h | 16 + .../pubsublite/mocks/mock_admin_connection.h | 15 + .../mocks/mock_topic_stats_connection.h | 15 + google/cloud/pubsublite/topic_stats_client.cc | 60 +++ google/cloud/pubsublite/topic_stats_client.h | 280 ++++++++++ .../pubsublite/topic_stats_connection.cc | 25 + .../cloud/pubsublite/topic_stats_connection.h | 13 + ...pic_stats_connection_idempotency_policy.cc | 20 + ...opic_stats_connection_idempotency_policy.h | 13 + .../rapidmigrationassessment/BUILD.bazel | 2 + ...pid_migration_assessment_auth_decorator.cc | 52 ++ ...apid_migration_assessment_auth_decorator.h | 24 + ...id_migration_assessment_connection_impl.cc | 123 +++++ ...pid_migration_assessment_connection_impl.h | 18 + ..._migration_assessment_logging_decorator.cc | 70 +++ ...d_migration_assessment_logging_decorator.h | 24 + ...migration_assessment_metadata_decorator.cc | 52 ++ ..._migration_assessment_metadata_decorator.h | 24 + .../rapid_migration_assessment_stub.cc | 70 +++ .../rapid_migration_assessment_stub.h | 63 ++- ...rapid_migration_assessment_stub_factory.cc | 9 +- ...migration_assessment_tracing_connection.cc | 62 +++ ..._migration_assessment_tracing_connection.h | 18 + ...rapid_migration_assessment_tracing_stub.cc | 76 +++ .../rapid_migration_assessment_tracing_stub.h | 24 + ...ck_rapid_migration_assessment_connection.h | 23 + .../v1/rapid_migration_assessment_client.cc | 76 +++ .../v1/rapid_migration_assessment_client.h | 350 +++++++++++++ .../rapid_migration_assessment_connection.cc | 38 ++ .../rapid_migration_assessment_connection.h | 18 + ...ssessment_connection_idempotency_policy.cc | 32 ++ ...assessment_connection_idempotency_policy.h | 20 + google/cloud/redis/BUILD.bazel | 2 + .../cluster/v1/cloud_redis_cluster_client.cc | 74 +++ .../cluster/v1/cloud_redis_cluster_client.h | 350 +++++++++++++ .../v1/cloud_redis_cluster_connection.cc | 38 ++ .../v1/cloud_redis_cluster_connection.h | 18 + ...s_cluster_connection_idempotency_policy.cc | 30 ++ ...is_cluster_connection_idempotency_policy.h | 20 + .../cloud_redis_cluster_auth_decorator.cc | 50 ++ .../cloud_redis_cluster_auth_decorator.h | 24 + .../cloud_redis_cluster_connection_impl.cc | 121 +++++ .../cloud_redis_cluster_connection_impl.h | 18 + .../cloud_redis_cluster_logging_decorator.cc | 69 +++ .../cloud_redis_cluster_logging_decorator.h | 24 + .../cloud_redis_cluster_metadata_decorator.cc | 52 ++ .../cloud_redis_cluster_metadata_decorator.h | 24 + .../v1/internal/cloud_redis_cluster_stub.cc | 70 +++ .../v1/internal/cloud_redis_cluster_stub.h | 63 ++- .../cloud_redis_cluster_stub_factory.cc | 9 +- .../cloud_redis_cluster_tracing_connection.cc | 56 ++ .../cloud_redis_cluster_tracing_connection.h | 18 + .../cloud_redis_cluster_tracing_stub.cc | 70 +++ .../cloud_redis_cluster_tracing_stub.h | 24 + .../mock_cloud_redis_cluster_connection.h | 23 + google/cloud/redis/v1/cloud_redis_client.cc | 69 +++ google/cloud/redis/v1/cloud_redis_client.h | 350 +++++++++++++ .../cloud/redis/v1/cloud_redis_connection.cc | 36 ++ .../cloud/redis/v1/cloud_redis_connection.h | 18 + ...oud_redis_connection_idempotency_policy.cc | 30 ++ ...loud_redis_connection_idempotency_policy.h | 20 + .../v1/internal/cloud_redis_auth_decorator.cc | 50 ++ .../v1/internal/cloud_redis_auth_decorator.h | 24 + .../internal/cloud_redis_connection_impl.cc | 120 +++++ .../v1/internal/cloud_redis_connection_impl.h | 18 + .../internal/cloud_redis_logging_decorator.cc | 68 +++ .../internal/cloud_redis_logging_decorator.h | 24 + .../cloud_redis_metadata_decorator.cc | 50 ++ .../internal/cloud_redis_metadata_decorator.h | 24 + .../redis/v1/internal/cloud_redis_stub.cc | 68 +++ .../redis/v1/internal/cloud_redis_stub.h | 63 ++- .../v1/internal/cloud_redis_stub_factory.cc | 9 +- .../cloud_redis_tracing_connection.cc | 55 ++ .../internal/cloud_redis_tracing_connection.h | 18 + .../v1/internal/cloud_redis_tracing_stub.cc | 68 +++ .../v1/internal/cloud_redis_tracing_stub.h | 24 + .../v1/mocks/mock_cloud_redis_connection.h | 23 + .../resourcemanager/v3/folders_client.cc | 14 + .../cloud/resourcemanager/v3/folders_client.h | 60 +++ .../resourcemanager/v3/folders_connection.cc | 5 + .../resourcemanager/v3/folders_connection.h | 3 + .../folders_connection_idempotency_policy.cc | 5 + .../folders_connection_idempotency_policy.h | 4 + .../v3/internal/folders_auth_decorator.cc | 8 + .../v3/internal/folders_auth_decorator.h | 4 + .../v3/internal/folders_connection_impl.cc | 13 + .../v3/internal/folders_connection_impl.h | 3 + .../v3/internal/folders_logging_decorator.cc | 11 + .../v3/internal/folders_logging_decorator.h | 4 + .../v3/internal/folders_metadata_decorator.cc | 8 + .../v3/internal/folders_metadata_decorator.h | 4 + .../v3/internal/folders_stub.cc | 11 + .../v3/internal/folders_stub.h | 16 +- .../v3/internal/folders_stub_factory.cc | 5 +- .../v3/internal/folders_tracing_connection.cc | 8 + .../v3/internal/folders_tracing_connection.h | 3 + .../v3/internal/folders_tracing_stub.cc | 11 + .../v3/internal/folders_tracing_stub.h | 4 + .../internal/organizations_auth_decorator.cc | 8 + .../internal/organizations_auth_decorator.h | 4 + .../internal/organizations_connection_impl.cc | 14 + .../internal/organizations_connection_impl.h | 3 + .../organizations_logging_decorator.cc | 11 + .../organizations_logging_decorator.h | 4 + .../organizations_metadata_decorator.cc | 8 + .../organizations_metadata_decorator.h | 4 + .../v3/internal/organizations_stub.cc | 11 + .../v3/internal/organizations_stub.h | 18 +- .../v3/internal/organizations_stub_factory.cc | 6 +- .../organizations_tracing_connection.cc | 9 + .../organizations_tracing_connection.h | 3 + .../v3/internal/organizations_tracing_stub.cc | 11 + .../v3/internal/organizations_tracing_stub.h | 4 + .../v3/internal/projects_auth_decorator.cc | 8 + .../v3/internal/projects_auth_decorator.h | 4 + .../v3/internal/projects_connection_impl.cc | 13 + .../v3/internal/projects_connection_impl.h | 3 + .../v3/internal/projects_logging_decorator.cc | 11 + .../v3/internal/projects_logging_decorator.h | 4 + .../internal/projects_metadata_decorator.cc | 8 + .../v3/internal/projects_metadata_decorator.h | 4 + .../v3/internal/projects_stub.cc | 11 + .../v3/internal/projects_stub.h | 16 +- .../v3/internal/projects_stub_factory.cc | 5 +- .../internal/projects_tracing_connection.cc | 9 + .../v3/internal/projects_tracing_connection.h | 3 + .../v3/internal/projects_tracing_stub.cc | 11 + .../v3/internal/projects_tracing_stub.h | 4 + .../internal/tag_bindings_auth_decorator.cc | 8 + .../v3/internal/tag_bindings_auth_decorator.h | 4 + .../internal/tag_bindings_connection_impl.cc | 14 + .../internal/tag_bindings_connection_impl.h | 3 + .../tag_bindings_logging_decorator.cc | 11 + .../internal/tag_bindings_logging_decorator.h | 4 + .../tag_bindings_metadata_decorator.cc | 8 + .../tag_bindings_metadata_decorator.h | 4 + .../v3/internal/tag_bindings_stub.cc | 11 + .../v3/internal/tag_bindings_stub.h | 16 +- .../v3/internal/tag_bindings_stub_factory.cc | 5 +- .../tag_bindings_tracing_connection.cc | 9 + .../tag_bindings_tracing_connection.h | 3 + .../v3/internal/tag_bindings_tracing_stub.cc | 11 + .../v3/internal/tag_bindings_tracing_stub.h | 4 + .../v3/internal/tag_holds_auth_decorator.cc | 8 + .../v3/internal/tag_holds_auth_decorator.h | 4 + .../v3/internal/tag_holds_connection_impl.cc | 13 + .../v3/internal/tag_holds_connection_impl.h | 3 + .../internal/tag_holds_logging_decorator.cc | 11 + .../v3/internal/tag_holds_logging_decorator.h | 4 + .../internal/tag_holds_metadata_decorator.cc | 8 + .../internal/tag_holds_metadata_decorator.h | 4 + .../v3/internal/tag_holds_stub.cc | 11 + .../v3/internal/tag_holds_stub.h | 16 +- .../v3/internal/tag_holds_stub_factory.cc | 5 +- .../internal/tag_holds_tracing_connection.cc | 9 + .../internal/tag_holds_tracing_connection.h | 3 + .../v3/internal/tag_holds_tracing_stub.cc | 11 + .../v3/internal/tag_holds_tracing_stub.h | 4 + .../v3/internal/tag_keys_auth_decorator.cc | 8 + .../v3/internal/tag_keys_auth_decorator.h | 4 + .../v3/internal/tag_keys_connection_impl.cc | 13 + .../v3/internal/tag_keys_connection_impl.h | 3 + .../v3/internal/tag_keys_logging_decorator.cc | 11 + .../v3/internal/tag_keys_logging_decorator.h | 4 + .../internal/tag_keys_metadata_decorator.cc | 8 + .../v3/internal/tag_keys_metadata_decorator.h | 4 + .../v3/internal/tag_keys_stub.cc | 11 + .../v3/internal/tag_keys_stub.h | 16 +- .../v3/internal/tag_keys_stub_factory.cc | 5 +- .../internal/tag_keys_tracing_connection.cc | 8 + .../v3/internal/tag_keys_tracing_connection.h | 3 + .../v3/internal/tag_keys_tracing_stub.cc | 11 + .../v3/internal/tag_keys_tracing_stub.h | 4 + .../v3/internal/tag_values_auth_decorator.cc | 8 + .../v3/internal/tag_values_auth_decorator.h | 4 + .../v3/internal/tag_values_connection_impl.cc | 13 + .../v3/internal/tag_values_connection_impl.h | 3 + .../internal/tag_values_logging_decorator.cc | 11 + .../internal/tag_values_logging_decorator.h | 4 + .../internal/tag_values_metadata_decorator.cc | 8 + .../internal/tag_values_metadata_decorator.h | 4 + .../v3/internal/tag_values_stub.cc | 11 + .../v3/internal/tag_values_stub.h | 16 +- .../v3/internal/tag_values_stub_factory.cc | 5 +- .../internal/tag_values_tracing_connection.cc | 9 + .../internal/tag_values_tracing_connection.h | 3 + .../v3/internal/tag_values_tracing_stub.cc | 11 + .../v3/internal/tag_values_tracing_stub.h | 4 + .../v3/mocks/mock_folders_connection.h | 4 + .../v3/mocks/mock_organizations_connection.h | 4 + .../v3/mocks/mock_projects_connection.h | 4 + .../v3/mocks/mock_tag_bindings_connection.h | 4 + .../v3/mocks/mock_tag_holds_connection.h | 4 + .../v3/mocks/mock_tag_keys_connection.h | 4 + .../v3/mocks/mock_tag_values_connection.h | 4 + .../v3/organizations_client.cc | 14 + .../resourcemanager/v3/organizations_client.h | 60 +++ .../v3/organizations_connection.cc | 5 + .../v3/organizations_connection.h | 3 + ...nizations_connection_idempotency_policy.cc | 5 + ...anizations_connection_idempotency_policy.h | 4 + .../resourcemanager/v3/projects_client.cc | 14 + .../resourcemanager/v3/projects_client.h | 60 +++ .../resourcemanager/v3/projects_connection.cc | 5 + .../resourcemanager/v3/projects_connection.h | 3 + .../projects_connection_idempotency_policy.cc | 5 + .../projects_connection_idempotency_policy.h | 4 + .../resourcemanager/v3/tag_bindings_client.cc | 14 + .../resourcemanager/v3/tag_bindings_client.h | 60 +++ .../v3/tag_bindings_connection.cc | 5 + .../v3/tag_bindings_connection.h | 3 + ..._bindings_connection_idempotency_policy.cc | 5 + ...g_bindings_connection_idempotency_policy.h | 4 + .../resourcemanager/v3/tag_holds_client.cc | 14 + .../resourcemanager/v3/tag_holds_client.h | 60 +++ .../v3/tag_holds_connection.cc | 5 + .../resourcemanager/v3/tag_holds_connection.h | 3 + ...tag_holds_connection_idempotency_policy.cc | 5 + .../tag_holds_connection_idempotency_policy.h | 4 + .../resourcemanager/v3/tag_keys_client.cc | 14 + .../resourcemanager/v3/tag_keys_client.h | 60 +++ .../resourcemanager/v3/tag_keys_connection.cc | 5 + .../resourcemanager/v3/tag_keys_connection.h | 3 + .../tag_keys_connection_idempotency_policy.cc | 5 + .../tag_keys_connection_idempotency_policy.h | 4 + .../resourcemanager/v3/tag_values_client.cc | 14 + .../resourcemanager/v3/tag_values_client.h | 60 +++ .../v3/tag_values_connection.cc | 5 + .../v3/tag_values_connection.h | 3 + ...ag_values_connection_idempotency_policy.cc | 5 + ...tag_values_connection_idempotency_policy.h | 4 + google/cloud/retail/BUILD.bazel | 2 + google/cloud/retail/v2/analytics_client.cc | 32 ++ google/cloud/retail/v2/analytics_client.h | 152 ++++++ .../cloud/retail/v2/analytics_connection.cc | 15 + google/cloud/retail/v2/analytics_connection.h | 7 + ...analytics_connection_idempotency_policy.cc | 10 + .../analytics_connection_idempotency_policy.h | 7 + google/cloud/retail/v2/catalog_client.cc | 31 ++ google/cloud/retail/v2/catalog_client.h | 152 ++++++ google/cloud/retail/v2/catalog_connection.cc | 13 + google/cloud/retail/v2/catalog_connection.h | 6 + .../catalog_connection_idempotency_policy.cc | 10 + .../catalog_connection_idempotency_policy.h | 7 + google/cloud/retail/v2/completion_client.cc | 32 ++ google/cloud/retail/v2/completion_client.h | 152 ++++++ .../cloud/retail/v2/completion_connection.cc | 15 + .../cloud/retail/v2/completion_connection.h | 7 + ...ompletion_connection_idempotency_policy.cc | 10 + ...completion_connection_idempotency_policy.h | 7 + google/cloud/retail/v2/control_client.cc | 31 ++ google/cloud/retail/v2/control_client.h | 152 ++++++ google/cloud/retail/v2/control_connection.cc | 13 + google/cloud/retail/v2/control_connection.h | 6 + .../control_connection_idempotency_policy.cc | 10 + .../control_connection_idempotency_policy.h | 7 + .../v2/internal/analytics_auth_decorator.cc | 17 + .../v2/internal/analytics_auth_decorator.h | 8 + .../v2/internal/analytics_connection_impl.cc | 48 ++ .../v2/internal/analytics_connection_impl.h | 7 + .../internal/analytics_logging_decorator.cc | 23 + .../v2/internal/analytics_logging_decorator.h | 8 + .../internal/analytics_metadata_decorator.cc | 17 + .../internal/analytics_metadata_decorator.h | 8 + .../retail/v2/internal/analytics_stub.cc | 24 + .../cloud/retail/v2/internal/analytics_stub.h | 24 +- .../v2/internal/analytics_stub_factory.cc | 5 +- .../internal/analytics_tracing_connection.cc | 21 + .../internal/analytics_tracing_connection.h | 6 + .../v2/internal/analytics_tracing_stub.cc | 24 + .../v2/internal/analytics_tracing_stub.h | 8 + .../v2/internal/catalog_auth_decorator.cc | 17 + .../v2/internal/catalog_auth_decorator.h | 8 + .../v2/internal/catalog_connection_impl.cc | 47 ++ .../v2/internal/catalog_connection_impl.h | 6 + .../v2/internal/catalog_logging_decorator.cc | 23 + .../v2/internal/catalog_logging_decorator.h | 8 + .../v2/internal/catalog_metadata_decorator.cc | 17 + .../v2/internal/catalog_metadata_decorator.h | 8 + .../cloud/retail/v2/internal/catalog_stub.cc | 24 + .../cloud/retail/v2/internal/catalog_stub.h | 26 +- .../v2/internal/catalog_stub_factory.cc | 6 +- .../v2/internal/catalog_tracing_connection.cc | 20 + .../v2/internal/catalog_tracing_connection.h | 6 + .../v2/internal/catalog_tracing_stub.cc | 24 + .../retail/v2/internal/catalog_tracing_stub.h | 8 + .../v2/internal/completion_auth_decorator.cc | 17 + .../v2/internal/completion_auth_decorator.h | 8 + .../v2/internal/completion_connection_impl.cc | 48 ++ .../v2/internal/completion_connection_impl.h | 7 + .../internal/completion_logging_decorator.cc | 23 + .../internal/completion_logging_decorator.h | 8 + .../internal/completion_metadata_decorator.cc | 18 + .../internal/completion_metadata_decorator.h | 8 + .../retail/v2/internal/completion_stub.cc | 24 + .../retail/v2/internal/completion_stub.h | 24 +- .../v2/internal/completion_stub_factory.cc | 5 +- .../internal/completion_tracing_connection.cc | 21 + .../internal/completion_tracing_connection.h | 6 + .../v2/internal/completion_tracing_stub.cc | 24 + .../v2/internal/completion_tracing_stub.h | 8 + .../v2/internal/control_auth_decorator.cc | 17 + .../v2/internal/control_auth_decorator.h | 8 + .../v2/internal/control_connection_impl.cc | 47 ++ .../v2/internal/control_connection_impl.h | 6 + .../v2/internal/control_logging_decorator.cc | 23 + .../v2/internal/control_logging_decorator.h | 8 + .../v2/internal/control_metadata_decorator.cc | 17 + .../v2/internal/control_metadata_decorator.h | 8 + .../cloud/retail/v2/internal/control_stub.cc | 24 + .../cloud/retail/v2/internal/control_stub.h | 26 +- .../v2/internal/control_stub_factory.cc | 6 +- .../v2/internal/control_tracing_connection.cc | 20 + .../v2/internal/control_tracing_connection.h | 6 + .../v2/internal/control_tracing_stub.cc | 24 + .../retail/v2/internal/control_tracing_stub.h | 8 + .../v2/internal/model_auth_decorator.cc | 17 + .../retail/v2/internal/model_auth_decorator.h | 8 + .../v2/internal/model_connection_impl.cc | 47 ++ .../v2/internal/model_connection_impl.h | 6 + .../v2/internal/model_logging_decorator.cc | 23 + .../v2/internal/model_logging_decorator.h | 8 + .../v2/internal/model_metadata_decorator.cc | 17 + .../v2/internal/model_metadata_decorator.h | 8 + google/cloud/retail/v2/internal/model_stub.cc | 23 + google/cloud/retail/v2/internal/model_stub.h | 24 +- .../retail/v2/internal/model_stub_factory.cc | 5 +- .../v2/internal/model_tracing_connection.cc | 20 + .../v2/internal/model_tracing_connection.h | 6 + .../retail/v2/internal/model_tracing_stub.cc | 23 + .../retail/v2/internal/model_tracing_stub.h | 8 + .../v2/internal/prediction_auth_decorator.cc | 17 + .../v2/internal/prediction_auth_decorator.h | 8 + .../v2/internal/prediction_connection_impl.cc | 48 ++ .../v2/internal/prediction_connection_impl.h | 7 + .../internal/prediction_logging_decorator.cc | 23 + .../internal/prediction_logging_decorator.h | 8 + .../internal/prediction_metadata_decorator.cc | 18 + .../internal/prediction_metadata_decorator.h | 8 + .../retail/v2/internal/prediction_stub.cc | 24 + .../retail/v2/internal/prediction_stub.h | 26 +- .../v2/internal/prediction_stub_factory.cc | 5 +- .../internal/prediction_tracing_connection.cc | 21 + .../internal/prediction_tracing_connection.h | 6 + .../v2/internal/prediction_tracing_stub.cc | 24 + .../v2/internal/prediction_tracing_stub.h | 8 + .../v2/internal/product_auth_decorator.cc | 17 + .../v2/internal/product_auth_decorator.h | 8 + .../v2/internal/product_connection_impl.cc | 47 ++ .../v2/internal/product_connection_impl.h | 6 + .../v2/internal/product_logging_decorator.cc | 23 + .../v2/internal/product_logging_decorator.h | 8 + .../v2/internal/product_metadata_decorator.cc | 17 + .../v2/internal/product_metadata_decorator.h | 8 + .../cloud/retail/v2/internal/product_stub.cc | 24 + .../cloud/retail/v2/internal/product_stub.h | 24 +- .../v2/internal/product_stub_factory.cc | 5 +- .../v2/internal/product_tracing_connection.cc | 20 + .../v2/internal/product_tracing_connection.h | 6 + .../v2/internal/product_tracing_stub.cc | 24 + .../retail/v2/internal/product_tracing_stub.h | 8 + .../v2/internal/search_auth_decorator.cc | 17 + .../v2/internal/search_auth_decorator.h | 8 + .../v2/internal/search_connection_impl.cc | 47 ++ .../v2/internal/search_connection_impl.h | 6 + .../v2/internal/search_logging_decorator.cc | 23 + .../v2/internal/search_logging_decorator.h | 8 + .../v2/internal/search_metadata_decorator.cc | 17 + .../v2/internal/search_metadata_decorator.h | 8 + .../cloud/retail/v2/internal/search_stub.cc | 23 + google/cloud/retail/v2/internal/search_stub.h | 26 +- .../retail/v2/internal/search_stub_factory.cc | 6 +- .../v2/internal/search_tracing_connection.cc | 20 + .../v2/internal/search_tracing_connection.h | 6 + .../retail/v2/internal/search_tracing_stub.cc | 23 + .../retail/v2/internal/search_tracing_stub.h | 8 + .../internal/serving_config_auth_decorator.cc | 17 + .../internal/serving_config_auth_decorator.h | 8 + .../serving_config_connection_impl.cc | 47 ++ .../internal/serving_config_connection_impl.h | 6 + .../serving_config_logging_decorator.cc | 24 + .../serving_config_logging_decorator.h | 8 + .../serving_config_metadata_decorator.cc | 18 + .../serving_config_metadata_decorator.h | 8 + .../retail/v2/internal/serving_config_stub.cc | 24 + .../retail/v2/internal/serving_config_stub.h | 26 +- .../internal/serving_config_stub_factory.cc | 5 +- .../serving_config_tracing_connection.cc | 20 + .../serving_config_tracing_connection.h | 6 + .../internal/serving_config_tracing_stub.cc | 24 + .../v2/internal/serving_config_tracing_stub.h | 8 + .../v2/internal/user_event_auth_decorator.cc | 17 + .../v2/internal/user_event_auth_decorator.h | 8 + .../v2/internal/user_event_connection_impl.cc | 48 ++ .../v2/internal/user_event_connection_impl.h | 7 + .../internal/user_event_logging_decorator.cc | 23 + .../internal/user_event_logging_decorator.h | 8 + .../internal/user_event_metadata_decorator.cc | 17 + .../internal/user_event_metadata_decorator.h | 8 + .../retail/v2/internal/user_event_stub.cc | 24 + .../retail/v2/internal/user_event_stub.h | 24 +- .../v2/internal/user_event_stub_factory.cc | 5 +- .../internal/user_event_tracing_connection.cc | 21 + .../internal/user_event_tracing_connection.h | 6 + .../v2/internal/user_event_tracing_stub.cc | 24 + .../v2/internal/user_event_tracing_stub.h | 8 + .../v2/mocks/mock_analytics_connection.h | 7 + .../retail/v2/mocks/mock_catalog_connection.h | 7 + .../v2/mocks/mock_completion_connection.h | 7 + .../retail/v2/mocks/mock_control_connection.h | 7 + .../retail/v2/mocks/mock_model_connection.h | 7 + .../v2/mocks/mock_prediction_connection.h | 7 + .../retail/v2/mocks/mock_product_connection.h | 7 + .../retail/v2/mocks/mock_search_connection.h | 7 + .../v2/mocks/mock_serving_config_connection.h | 7 + .../v2/mocks/mock_user_event_connection.h | 7 + google/cloud/retail/v2/model_client.cc | 29 ++ google/cloud/retail/v2/model_client.h | 152 ++++++ google/cloud/retail/v2/model_connection.cc | 13 + google/cloud/retail/v2/model_connection.h | 6 + .../v2/model_connection_idempotency_policy.cc | 10 + .../v2/model_connection_idempotency_policy.h | 7 + google/cloud/retail/v2/prediction_client.cc | 32 ++ google/cloud/retail/v2/prediction_client.h | 152 ++++++ .../cloud/retail/v2/prediction_connection.cc | 15 + .../cloud/retail/v2/prediction_connection.h | 7 + ...rediction_connection_idempotency_policy.cc | 10 + ...prediction_connection_idempotency_policy.h | 7 + google/cloud/retail/v2/product_client.cc | 31 ++ google/cloud/retail/v2/product_client.h | 152 ++++++ google/cloud/retail/v2/product_connection.cc | 13 + google/cloud/retail/v2/product_connection.h | 6 + .../product_connection_idempotency_policy.cc | 10 + .../product_connection_idempotency_policy.h | 7 + google/cloud/retail/v2/search_client.cc | 29 ++ google/cloud/retail/v2/search_client.h | 152 ++++++ google/cloud/retail/v2/search_connection.cc | 13 + google/cloud/retail/v2/search_connection.h | 6 + .../search_connection_idempotency_policy.cc | 10 + .../v2/search_connection_idempotency_policy.h | 7 + .../cloud/retail/v2/serving_config_client.cc | 34 ++ .../cloud/retail/v2/serving_config_client.h | 152 ++++++ .../retail/v2/serving_config_connection.cc | 14 + .../retail/v2/serving_config_connection.h | 6 + ...ng_config_connection_idempotency_policy.cc | 10 + ...ing_config_connection_idempotency_policy.h | 7 + google/cloud/retail/v2/user_event_client.cc | 32 ++ google/cloud/retail/v2/user_event_client.h | 152 ++++++ .../cloud/retail/v2/user_event_connection.cc | 15 + .../cloud/retail/v2/user_event_connection.h | 7 + ...ser_event_connection_idempotency_policy.cc | 10 + ...user_event_connection_idempotency_policy.h | 7 + google/cloud/run/BUILD.bazel | 2 + google/cloud/run/v2/executions_client.cc | 49 ++ google/cloud/run/v2/executions_client.h | 246 +++++++++ google/cloud/run/v2/executions_connection.cc | 23 + google/cloud/run/v2/executions_connection.h | 12 + ...xecutions_connection_idempotency_policy.cc | 20 + ...executions_connection_idempotency_policy.h | 13 + .../v2/internal/executions_auth_decorator.cc | 33 ++ .../v2/internal/executions_auth_decorator.h | 16 + .../v2/internal/executions_connection_impl.cc | 73 +++ .../v2/internal/executions_connection_impl.h | 12 + .../internal/executions_logging_decorator.cc | 45 ++ .../internal/executions_logging_decorator.h | 16 + .../internal/executions_metadata_decorator.cc | 32 ++ .../internal/executions_metadata_decorator.h | 16 + .../cloud/run/v2/internal/executions_stub.cc | 45 ++ .../cloud/run/v2/internal/executions_stub.h | 40 +- .../v2/internal/executions_stub_factory.cc | 5 +- .../internal/executions_tracing_connection.cc | 35 ++ .../internal/executions_tracing_connection.h | 12 + .../v2/internal/executions_tracing_stub.cc | 45 ++ .../run/v2/internal/executions_tracing_stub.h | 16 + .../run/v2/internal/jobs_auth_decorator.cc | 32 ++ .../run/v2/internal/jobs_auth_decorator.h | 16 + .../run/v2/internal/jobs_connection_impl.cc | 70 +++ .../run/v2/internal/jobs_connection_impl.h | 12 + .../run/v2/internal/jobs_logging_decorator.cc | 45 ++ .../run/v2/internal/jobs_logging_decorator.h | 16 + .../v2/internal/jobs_metadata_decorator.cc | 32 ++ .../run/v2/internal/jobs_metadata_decorator.h | 16 + google/cloud/run/v2/internal/jobs_stub.cc | 45 ++ google/cloud/run/v2/internal/jobs_stub.h | 40 +- .../run/v2/internal/jobs_stub_factory.cc | 5 +- .../v2/internal/jobs_tracing_connection.cc | 31 ++ .../run/v2/internal/jobs_tracing_connection.h | 12 + .../run/v2/internal/jobs_tracing_stub.cc | 45 ++ .../cloud/run/v2/internal/jobs_tracing_stub.h | 16 + .../v2/internal/revisions_auth_decorator.cc | 33 ++ .../v2/internal/revisions_auth_decorator.h | 16 + .../v2/internal/revisions_connection_impl.cc | 72 +++ .../v2/internal/revisions_connection_impl.h | 12 + .../internal/revisions_logging_decorator.cc | 45 ++ .../v2/internal/revisions_logging_decorator.h | 16 + .../internal/revisions_metadata_decorator.cc | 32 ++ .../internal/revisions_metadata_decorator.h | 16 + .../cloud/run/v2/internal/revisions_stub.cc | 45 ++ google/cloud/run/v2/internal/revisions_stub.h | 40 +- .../run/v2/internal/revisions_stub_factory.cc | 5 +- .../internal/revisions_tracing_connection.cc | 34 ++ .../internal/revisions_tracing_connection.h | 12 + .../run/v2/internal/revisions_tracing_stub.cc | 45 ++ .../run/v2/internal/revisions_tracing_stub.h | 16 + .../v2/internal/services_auth_decorator.cc | 33 ++ .../run/v2/internal/services_auth_decorator.h | 16 + .../v2/internal/services_connection_impl.cc | 72 +++ .../v2/internal/services_connection_impl.h | 12 + .../v2/internal/services_logging_decorator.cc | 45 ++ .../v2/internal/services_logging_decorator.h | 16 + .../internal/services_metadata_decorator.cc | 32 ++ .../v2/internal/services_metadata_decorator.h | 16 + google/cloud/run/v2/internal/services_stub.cc | 45 ++ google/cloud/run/v2/internal/services_stub.h | 40 +- .../run/v2/internal/services_stub_factory.cc | 5 +- .../internal/services_tracing_connection.cc | 33 ++ .../v2/internal/services_tracing_connection.h | 12 + .../run/v2/internal/services_tracing_stub.cc | 45 ++ .../run/v2/internal/services_tracing_stub.h | 16 + .../run/v2/internal/tasks_auth_decorator.cc | 32 ++ .../run/v2/internal/tasks_auth_decorator.h | 16 + .../run/v2/internal/tasks_connection_impl.cc | 71 +++ .../run/v2/internal/tasks_connection_impl.h | 12 + .../v2/internal/tasks_logging_decorator.cc | 45 ++ .../run/v2/internal/tasks_logging_decorator.h | 16 + .../v2/internal/tasks_metadata_decorator.cc | 32 ++ .../v2/internal/tasks_metadata_decorator.h | 16 + google/cloud/run/v2/internal/tasks_stub.cc | 45 ++ google/cloud/run/v2/internal/tasks_stub.h | 42 +- .../run/v2/internal/tasks_stub_factory.cc | 7 +- .../v2/internal/tasks_tracing_connection.cc | 31 ++ .../v2/internal/tasks_tracing_connection.h | 12 + .../run/v2/internal/tasks_tracing_stub.cc | 45 ++ .../run/v2/internal/tasks_tracing_stub.h | 16 + google/cloud/run/v2/jobs_client.cc | 48 ++ google/cloud/run/v2/jobs_client.h | 246 +++++++++ google/cloud/run/v2/jobs_connection.cc | 22 + google/cloud/run/v2/jobs_connection.h | 12 + .../v2/jobs_connection_idempotency_policy.cc | 20 + .../v2/jobs_connection_idempotency_policy.h | 13 + .../run/v2/mocks/mock_executions_connection.h | 15 + .../cloud/run/v2/mocks/mock_jobs_connection.h | 15 + .../run/v2/mocks/mock_revisions_connection.h | 15 + .../run/v2/mocks/mock_services_connection.h | 15 + .../run/v2/mocks/mock_tasks_connection.h | 15 + google/cloud/run/v2/revisions_client.cc | 48 ++ google/cloud/run/v2/revisions_client.h | 246 +++++++++ google/cloud/run/v2/revisions_connection.cc | 22 + google/cloud/run/v2/revisions_connection.h | 12 + ...revisions_connection_idempotency_policy.cc | 20 + .../revisions_connection_idempotency_policy.h | 13 + google/cloud/run/v2/services_client.cc | 48 ++ google/cloud/run/v2/services_client.h | 246 +++++++++ google/cloud/run/v2/services_connection.cc | 22 + google/cloud/run/v2/services_connection.h | 12 + .../services_connection_idempotency_policy.cc | 20 + .../services_connection_idempotency_policy.h | 13 + google/cloud/run/v2/tasks_client.cc | 48 ++ google/cloud/run/v2/tasks_client.h | 246 +++++++++ google/cloud/run/v2/tasks_connection.cc | 22 + google/cloud/run/v2/tasks_connection.h | 12 + .../v2/tasks_connection_idempotency_policy.cc | 20 + .../v2/tasks_connection_idempotency_policy.h | 13 + 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 | 6 + ...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 | 27 +- .../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 | 27 +- .../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 | 6 + ...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 | 76 +++ .../secure_source_manager_auth_decorator.h | 36 ++ .../secure_source_manager_connection_impl.cc | 165 ++++++ .../secure_source_manager_connection_impl.h | 27 + ...secure_source_manager_logging_decorator.cc | 104 ++++ .../secure_source_manager_logging_decorator.h | 36 ++ ...ecure_source_manager_metadata_decorator.cc | 80 +++ ...secure_source_manager_metadata_decorator.h | 36 ++ .../v1/internal/secure_source_manager_stub.cc | 105 ++++ .../v1/internal/secure_source_manager_stub.h | 92 +++- .../secure_source_manager_stub_factory.cc | 11 +- ...ecure_source_manager_tracing_connection.cc | 84 +++ ...secure_source_manager_tracing_connection.h | 27 + .../secure_source_manager_tracing_stub.cc | 112 ++++ .../secure_source_manager_tracing_stub.h | 36 ++ .../mock_secure_source_manager_connection.h | 36 ++ .../v1/secure_source_manager_client.cc | 94 ++++ .../v1/secure_source_manager_client.h | 452 ++++++++++++++++ .../v1/secure_source_manager_connection.cc | 54 ++ .../v1/secure_source_manager_connection.h | 27 + ...e_manager_connection_idempotency_policy.cc | 46 ++ ...ce_manager_connection_idempotency_policy.h | 30 ++ .../security_center_auth_decorator.cc | 33 ++ .../internal/security_center_auth_decorator.h | 16 + .../security_center_connection_impl.cc | 73 +++ .../security_center_connection_impl.h | 12 + .../security_center_logging_decorator.cc | 45 ++ .../security_center_logging_decorator.h | 16 + .../security_center_metadata_decorator.cc | 33 ++ .../security_center_metadata_decorator.h | 16 + .../v1/internal/security_center_stub.cc | 46 ++ .../v1/internal/security_center_stub.h | 40 +- .../internal/security_center_stub_factory.cc | 5 +- .../security_center_tracing_connection.cc | 36 ++ .../security_center_tracing_connection.h | 12 + .../internal/security_center_tracing_stub.cc | 46 ++ .../internal/security_center_tracing_stub.h | 16 + .../mocks/mock_security_center_connection.h | 15 + .../v1/security_center_client.cc | 59 +++ .../v1/security_center_client.h | 280 ++++++++++ .../v1/security_center_connection.cc | 23 + .../v1/security_center_connection.h | 12 + ...ty_center_connection_idempotency_policy.cc | 20 + ...ity_center_connection_idempotency_policy.h | 13 + .../security_center_auth_decorator.cc | 33 ++ .../internal/security_center_auth_decorator.h | 16 + .../security_center_connection_impl.cc | 73 +++ .../security_center_connection_impl.h | 12 + .../security_center_logging_decorator.cc | 45 ++ .../security_center_logging_decorator.h | 16 + .../security_center_metadata_decorator.cc | 33 ++ .../security_center_metadata_decorator.h | 16 + .../v2/internal/security_center_stub.cc | 46 ++ .../v2/internal/security_center_stub.h | 40 +- .../internal/security_center_stub_factory.cc | 5 +- .../security_center_tracing_connection.cc | 36 ++ .../security_center_tracing_connection.h | 12 + .../internal/security_center_tracing_stub.cc | 46 ++ .../internal/security_center_tracing_stub.h | 16 + .../mocks/mock_security_center_connection.h | 15 + .../v2/security_center_client.cc | 59 +++ .../v2/security_center_client.h | 280 ++++++++++ .../v2/security_center_connection.cc | 23 + .../v2/security_center_connection.h | 12 + ...ty_center_connection_idempotency_policy.cc | 20 + ...ity_center_connection_idempotency_policy.h | 13 + .../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 | 27 +- ...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 | 6 + ...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 | 27 +- .../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 | 27 +- .../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 | 7 + .../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 | 6 + ...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 | 27 +- .../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 | 6 + ...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 | 34 ++ .../internal/service_manager_auth_decorator.h | 16 + .../service_manager_connection_impl.cc | 73 +++ .../service_manager_connection_impl.h | 12 + .../service_manager_logging_decorator.cc | 46 ++ .../service_manager_logging_decorator.h | 16 + .../service_manager_metadata_decorator.cc | 36 ++ .../service_manager_metadata_decorator.h | 16 + .../v1/internal/service_manager_stub.cc | 47 ++ .../v1/internal/service_manager_stub.h | 45 +- .../internal/service_manager_stub_factory.cc | 8 +- .../service_manager_tracing_connection.cc | 36 ++ .../service_manager_tracing_connection.h | 12 + .../internal/service_manager_tracing_stub.cc | 46 ++ .../internal/service_manager_tracing_stub.h | 16 + .../mocks/mock_service_manager_connection.h | 16 + .../v1/service_manager_client.cc | 36 ++ .../v1/service_manager_client.h | 194 +++++++ .../v1/service_manager_connection.cc | 24 + .../v1/service_manager_connection.h | 12 + ...e_manager_connection_idempotency_policy.cc | 21 + ...ce_manager_connection_idempotency_policy.h | 14 + .../internal/service_usage_auth_decorator.cc | 17 + .../internal/service_usage_auth_decorator.h | 8 + .../internal/service_usage_connection_impl.cc | 47 ++ .../internal/service_usage_connection_impl.h | 6 + .../service_usage_logging_decorator.cc | 23 + .../service_usage_logging_decorator.h | 8 + .../service_usage_metadata_decorator.cc | 16 + .../service_usage_metadata_decorator.h | 8 + .../v1/internal/service_usage_stub.cc | 23 + .../v1/internal/service_usage_stub.h | 24 +- .../v1/internal/service_usage_stub_factory.cc | 5 +- .../service_usage_tracing_connection.cc | 20 + .../service_usage_tracing_connection.h | 6 + .../v1/internal/service_usage_tracing_stub.cc | 23 + .../v1/internal/service_usage_tracing_stub.h | 8 + .../v1/mocks/mock_service_usage_connection.h | 7 + .../serviceusage/v1/service_usage_client.cc | 29 ++ .../serviceusage/v1/service_usage_client.h | 152 ++++++ .../v1/service_usage_connection.cc | 13 + .../v1/service_usage_connection.h | 6 + ...ice_usage_connection_idempotency_policy.cc | 10 + ...vice_usage_connection_idempotency_policy.h | 7 + .../spanner/admin/database_admin_client.cc | 57 ++ .../spanner/admin/database_admin_client.h | 280 ++++++++++ .../admin/database_admin_connection.cc | 23 + .../spanner/admin/database_admin_connection.h | 12 + ...ase_admin_connection_idempotency_policy.cc | 20 + ...base_admin_connection_idempotency_policy.h | 13 + .../internal/database_admin_auth_decorator.cc | 33 ++ .../internal/database_admin_auth_decorator.h | 16 + .../database_admin_connection_impl.cc | 73 +++ .../internal/database_admin_connection_impl.h | 12 + .../database_admin_logging_decorator.cc | 45 ++ .../database_admin_logging_decorator.h | 16 + .../database_admin_metadata_decorator.cc | 33 ++ .../database_admin_metadata_decorator.h | 16 + .../database_admin_rest_connection_impl.cc | 74 +++ .../database_admin_rest_connection_impl.h | 12 + .../database_admin_rest_logging_decorator.cc | 45 ++ .../database_admin_rest_logging_decorator.h | 20 + .../database_admin_rest_metadata_decorator.cc | 30 ++ .../database_admin_rest_metadata_decorator.h | 20 + .../internal/database_admin_rest_stub.cc | 55 ++ .../admin/internal/database_admin_rest_stub.h | 40 ++ .../admin/internal/database_admin_stub.cc | 45 ++ .../admin/internal/database_admin_stub.h | 40 +- .../internal/database_admin_stub_factory.cc | 5 +- .../database_admin_tracing_connection.cc | 36 ++ .../database_admin_tracing_connection.h | 12 + .../internal/database_admin_tracing_stub.cc | 45 ++ .../internal/database_admin_tracing_stub.h | 16 + .../mocks/mock_database_admin_connection.h | 15 + google/cloud/speech/BUILD.bazel | 2 + google/cloud/speech/v1/adaptation_client.cc | 29 ++ google/cloud/speech/v1/adaptation_client.h | 152 ++++++ .../cloud/speech/v1/adaptation_connection.cc | 13 + .../cloud/speech/v1/adaptation_connection.h | 6 + ...daptation_connection_idempotency_policy.cc | 10 + ...adaptation_connection_idempotency_policy.h | 7 + .../v1/internal/adaptation_auth_decorator.cc | 17 + .../v1/internal/adaptation_auth_decorator.h | 8 + .../v1/internal/adaptation_connection_impl.cc | 46 ++ .../v1/internal/adaptation_connection_impl.h | 6 + .../internal/adaptation_logging_decorator.cc | 23 + .../internal/adaptation_logging_decorator.h | 8 + .../internal/adaptation_metadata_decorator.cc | 16 + .../internal/adaptation_metadata_decorator.h | 8 + .../speech/v1/internal/adaptation_stub.cc | 23 + .../speech/v1/internal/adaptation_stub.h | 26 +- .../v1/internal/adaptation_stub_factory.cc | 6 +- .../internal/adaptation_tracing_connection.cc | 20 + .../internal/adaptation_tracing_connection.h | 6 + .../v1/internal/adaptation_tracing_stub.cc | 23 + .../v1/internal/adaptation_tracing_stub.h | 8 + .../v1/internal/speech_auth_decorator.cc | 17 + .../v1/internal/speech_auth_decorator.h | 8 + .../v1/internal/speech_connection_impl.cc | 47 ++ .../v1/internal/speech_connection_impl.h | 7 + .../v1/internal/speech_logging_decorator.cc | 23 + .../v1/internal/speech_logging_decorator.h | 8 + .../v1/internal/speech_metadata_decorator.cc | 16 + .../v1/internal/speech_metadata_decorator.h | 8 + .../cloud/speech/v1/internal/speech_stub.cc | 23 + google/cloud/speech/v1/internal/speech_stub.h | 24 +- .../speech/v1/internal/speech_stub_factory.cc | 5 +- .../v1/internal/speech_tracing_connection.cc | 18 + .../v1/internal/speech_tracing_connection.h | 6 + .../speech/v1/internal/speech_tracing_stub.cc | 23 + .../speech/v1/internal/speech_tracing_stub.h | 8 + .../v1/mocks/mock_adaptation_connection.h | 7 + .../speech/v1/mocks/mock_speech_connection.h | 7 + google/cloud/speech/v1/speech_client.cc | 29 ++ google/cloud/speech/v1/speech_client.h | 152 ++++++ google/cloud/speech/v1/speech_connection.cc | 13 + google/cloud/speech/v1/speech_connection.h | 7 + .../speech_connection_idempotency_policy.cc | 10 + .../v1/speech_connection_idempotency_policy.h | 7 + .../v2/internal/speech_auth_decorator.cc | 50 ++ .../v2/internal/speech_auth_decorator.h | 24 + .../v2/internal/speech_connection_impl.cc | 119 +++++ .../v2/internal/speech_connection_impl.h | 18 + .../v2/internal/speech_logging_decorator.cc | 68 +++ .../v2/internal/speech_logging_decorator.h | 24 + .../v2/internal/speech_metadata_decorator.cc | 50 ++ .../v2/internal/speech_metadata_decorator.h | 24 + .../cloud/speech/v2/internal/speech_stub.cc | 68 +++ google/cloud/speech/v2/internal/speech_stub.h | 63 ++- .../speech/v2/internal/speech_stub_factory.cc | 9 +- .../v2/internal/speech_tracing_connection.cc | 51 ++ .../v2/internal/speech_tracing_connection.h | 18 + .../speech/v2/internal/speech_tracing_stub.cc | 68 +++ .../speech/v2/internal/speech_tracing_stub.h | 24 + .../speech/v2/mocks/mock_speech_connection.h | 23 + google/cloud/speech/v2/speech_client.cc | 67 +++ google/cloud/speech/v2/speech_client.h | 350 +++++++++++++ google/cloud/speech/v2/speech_connection.cc | 34 ++ google/cloud/speech/v2/speech_connection.h | 18 + .../speech_connection_idempotency_policy.cc | 30 ++ .../v2/speech_connection_idempotency_policy.h | 20 + google/cloud/sql/BUILD.bazel | 2 + google/cloud/storageinsights/BUILD.bazel | 2 + .../storage_insights_auth_decorator.cc | 50 ++ .../storage_insights_auth_decorator.h | 24 + .../storage_insights_connection_impl.cc | 121 +++++ .../storage_insights_connection_impl.h | 18 + .../storage_insights_logging_decorator.cc | 68 +++ .../storage_insights_logging_decorator.h | 24 + .../storage_insights_metadata_decorator.cc | 51 ++ .../storage_insights_metadata_decorator.h | 24 + .../v1/internal/storage_insights_stub.cc | 70 +++ .../v1/internal/storage_insights_stub.h | 65 ++- .../internal/storage_insights_stub_factory.cc | 9 +- .../storage_insights_tracing_connection.cc | 56 ++ .../storage_insights_tracing_connection.h | 18 + .../internal/storage_insights_tracing_stub.cc | 70 +++ .../internal/storage_insights_tracing_stub.h | 24 + .../mocks/mock_storage_insights_connection.h | 23 + .../v1/storage_insights_client.cc | 72 +++ .../v1/storage_insights_client.h | 350 +++++++++++++ .../v1/storage_insights_connection.cc | 38 ++ .../v1/storage_insights_connection.h | 18 + ..._insights_connection_idempotency_policy.cc | 30 ++ ...e_insights_connection_idempotency_policy.h | 20 + .../storage_transfer_auth_decorator.cc | 26 + .../storage_transfer_auth_decorator.h | 12 + .../storage_transfer_connection_impl.cc | 61 +++ .../storage_transfer_connection_impl.h | 9 + .../storage_transfer_logging_decorator.cc | 35 ++ .../storage_transfer_logging_decorator.h | 12 + .../storage_transfer_metadata_decorator.cc | 26 + .../storage_transfer_metadata_decorator.h | 12 + .../v1/internal/storage_transfer_stub.cc | 35 ++ .../v1/internal/storage_transfer_stub.h | 32 +- .../internal/storage_transfer_stub_factory.cc | 5 +- .../storage_transfer_tracing_connection.cc | 28 + .../storage_transfer_tracing_connection.h | 9 + .../internal/storage_transfer_tracing_stub.cc | 35 ++ .../internal/storage_transfer_tracing_stub.h | 12 + .../mocks/mock_storage_transfer_connection.h | 11 + .../v1/storage_transfer_client.cc | 48 ++ .../v1/storage_transfer_client.h | 225 ++++++++ .../v1/storage_transfer_connection.cc | 19 + .../v1/storage_transfer_connection.h | 9 + ..._transfer_connection_idempotency_policy.cc | 15 + ...e_transfer_connection_idempotency_policy.h | 10 + google/cloud/talent/v4/company_client.cc | 14 + google/cloud/talent/v4/company_client.h | 60 +++ google/cloud/talent/v4/company_connection.cc | 5 + google/cloud/talent/v4/company_connection.h | 3 + .../company_connection_idempotency_policy.cc | 5 + .../company_connection_idempotency_policy.h | 4 + google/cloud/talent/v4/completion_client.cc | 14 + google/cloud/talent/v4/completion_client.h | 60 +++ .../cloud/talent/v4/completion_connection.cc | 5 + .../cloud/talent/v4/completion_connection.h | 3 + ...ompletion_connection_idempotency_policy.cc | 5 + ...completion_connection_idempotency_policy.h | 4 + google/cloud/talent/v4/event_client.cc | 14 + google/cloud/talent/v4/event_client.h | 60 +++ google/cloud/talent/v4/event_connection.cc | 5 + google/cloud/talent/v4/event_connection.h | 3 + .../v4/event_connection_idempotency_policy.cc | 5 + .../v4/event_connection_idempotency_policy.h | 4 + .../v4/internal/company_auth_decorator.cc | 8 + .../v4/internal/company_auth_decorator.h | 4 + .../v4/internal/company_connection_impl.cc | 14 + .../v4/internal/company_connection_impl.h | 3 + .../v4/internal/company_logging_decorator.cc | 11 + .../v4/internal/company_logging_decorator.h | 4 + .../v4/internal/company_metadata_decorator.cc | 8 + .../v4/internal/company_metadata_decorator.h | 4 + .../cloud/talent/v4/internal/company_stub.cc | 12 + .../cloud/talent/v4/internal/company_stub.h | 18 +- .../v4/internal/company_stub_factory.cc | 6 +- .../v4/internal/company_tracing_connection.cc | 9 + .../v4/internal/company_tracing_connection.h | 3 + .../v4/internal/company_tracing_stub.cc | 12 + .../talent/v4/internal/company_tracing_stub.h | 4 + .../v4/internal/completion_auth_decorator.cc | 8 + .../v4/internal/completion_auth_decorator.h | 4 + .../v4/internal/completion_connection_impl.cc | 13 + .../v4/internal/completion_connection_impl.h | 3 + .../internal/completion_logging_decorator.cc | 11 + .../internal/completion_logging_decorator.h | 4 + .../internal/completion_metadata_decorator.cc | 8 + .../internal/completion_metadata_decorator.h | 4 + .../talent/v4/internal/completion_stub.cc | 11 + .../talent/v4/internal/completion_stub.h | 18 +- .../v4/internal/completion_stub_factory.cc | 6 +- .../internal/completion_tracing_connection.cc | 9 + .../internal/completion_tracing_connection.h | 3 + .../v4/internal/completion_tracing_stub.cc | 11 + .../v4/internal/completion_tracing_stub.h | 4 + .../v4/internal/event_auth_decorator.cc | 8 + .../talent/v4/internal/event_auth_decorator.h | 4 + .../v4/internal/event_connection_impl.cc | 14 + .../v4/internal/event_connection_impl.h | 3 + .../v4/internal/event_logging_decorator.cc | 11 + .../v4/internal/event_logging_decorator.h | 4 + .../v4/internal/event_metadata_decorator.cc | 8 + .../v4/internal/event_metadata_decorator.h | 4 + google/cloud/talent/v4/internal/event_stub.cc | 11 + google/cloud/talent/v4/internal/event_stub.h | 18 +- .../talent/v4/internal/event_stub_factory.cc | 6 +- .../v4/internal/event_tracing_connection.cc | 9 + .../v4/internal/event_tracing_connection.h | 3 + .../talent/v4/internal/event_tracing_stub.cc | 11 + .../talent/v4/internal/event_tracing_stub.h | 4 + .../talent/v4/internal/job_auth_decorator.cc | 8 + .../talent/v4/internal/job_auth_decorator.h | 4 + .../talent/v4/internal/job_connection_impl.cc | 13 + .../talent/v4/internal/job_connection_impl.h | 3 + .../v4/internal/job_logging_decorator.cc | 11 + .../v4/internal/job_logging_decorator.h | 4 + .../v4/internal/job_metadata_decorator.cc | 8 + .../v4/internal/job_metadata_decorator.h | 4 + google/cloud/talent/v4/internal/job_stub.cc | 11 + google/cloud/talent/v4/internal/job_stub.h | 16 +- .../talent/v4/internal/job_stub_factory.cc | 5 +- .../v4/internal/job_tracing_connection.cc | 9 + .../v4/internal/job_tracing_connection.h | 3 + .../talent/v4/internal/job_tracing_stub.cc | 11 + .../talent/v4/internal/job_tracing_stub.h | 4 + .../v4/internal/tenant_auth_decorator.cc | 8 + .../v4/internal/tenant_auth_decorator.h | 4 + .../v4/internal/tenant_connection_impl.cc | 14 + .../v4/internal/tenant_connection_impl.h | 3 + .../v4/internal/tenant_logging_decorator.cc | 11 + .../v4/internal/tenant_logging_decorator.h | 4 + .../v4/internal/tenant_metadata_decorator.cc | 8 + .../v4/internal/tenant_metadata_decorator.h | 4 + .../cloud/talent/v4/internal/tenant_stub.cc | 11 + google/cloud/talent/v4/internal/tenant_stub.h | 18 +- .../talent/v4/internal/tenant_stub_factory.cc | 6 +- .../v4/internal/tenant_tracing_connection.cc | 9 + .../v4/internal/tenant_tracing_connection.h | 3 + .../talent/v4/internal/tenant_tracing_stub.cc | 11 + .../talent/v4/internal/tenant_tracing_stub.h | 4 + google/cloud/talent/v4/job_client.cc | 14 + google/cloud/talent/v4/job_client.h | 60 +++ google/cloud/talent/v4/job_connection.cc | 5 + google/cloud/talent/v4/job_connection.h | 3 + .../v4/job_connection_idempotency_policy.cc | 5 + .../v4/job_connection_idempotency_policy.h | 4 + .../talent/v4/mocks/mock_company_connection.h | 4 + .../v4/mocks/mock_completion_connection.h | 4 + .../talent/v4/mocks/mock_event_connection.h | 4 + .../talent/v4/mocks/mock_job_connection.h | 4 + .../talent/v4/mocks/mock_tenant_connection.h | 4 + google/cloud/talent/v4/tenant_client.cc | 14 + google/cloud/talent/v4/tenant_client.h | 60 +++ google/cloud/talent/v4/tenant_connection.cc | 5 + google/cloud/talent/v4/tenant_connection.h | 3 + .../tenant_connection_idempotency_policy.cc | 5 + .../v4/tenant_connection_idempotency_policy.h | 4 + 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 | 6 + ...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 | 27 +- .../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 | 50 ++ .../telco_automation_auth_decorator.h | 24 + .../telco_automation_connection_impl.cc | 121 +++++ .../telco_automation_connection_impl.h | 18 + .../telco_automation_logging_decorator.cc | 68 +++ .../telco_automation_logging_decorator.h | 24 + .../telco_automation_metadata_decorator.cc | 51 ++ .../telco_automation_metadata_decorator.h | 24 + .../v1/internal/telco_automation_stub.cc | 70 +++ .../v1/internal/telco_automation_stub.h | 63 ++- .../internal/telco_automation_stub_factory.cc | 9 +- .../telco_automation_tracing_connection.cc | 56 ++ .../telco_automation_tracing_connection.h | 18 + .../internal/telco_automation_tracing_stub.cc | 70 +++ .../internal/telco_automation_tracing_stub.h | 24 + .../mocks/mock_telco_automation_connection.h | 23 + .../v1/telco_automation_client.cc | 72 +++ .../v1/telco_automation_client.h | 350 +++++++++++++ .../v1/telco_automation_connection.cc | 38 ++ .../v1/telco_automation_connection.h | 18 + ...utomation_connection_idempotency_policy.cc | 30 ++ ...automation_connection_idempotency_policy.h | 20 + .../internal/text_to_speech_auth_decorator.cc | 17 + .../internal/text_to_speech_auth_decorator.h | 8 + .../text_to_speech_connection_impl.cc | 48 ++ .../internal/text_to_speech_connection_impl.h | 7 + .../text_to_speech_logging_decorator.cc | 23 + .../text_to_speech_logging_decorator.h | 8 + .../text_to_speech_metadata_decorator.cc | 17 + .../text_to_speech_metadata_decorator.h | 8 + .../v1/internal/text_to_speech_stub.cc | 23 + .../v1/internal/text_to_speech_stub.h | 26 +- .../internal/text_to_speech_stub_factory.cc | 6 +- .../text_to_speech_tracing_connection.cc | 21 + .../text_to_speech_tracing_connection.h | 6 + .../internal/text_to_speech_tracing_stub.cc | 23 + .../v1/internal/text_to_speech_tracing_stub.h | 8 + .../v1/mocks/mock_text_to_speech_connection.h | 7 + .../texttospeech/v1/text_to_speech_client.cc | 29 ++ .../texttospeech/v1/text_to_speech_client.h | 152 ++++++ .../v1/text_to_speech_connection.cc | 14 + .../v1/text_to_speech_connection.h | 7 + ...to_speech_connection_idempotency_policy.cc | 10 + ..._to_speech_connection_idempotency_policy.h | 7 + google/cloud/timeseriesinsights/BUILD.bazel | 2 + google/cloud/tpu/BUILD.bazel | 2 + .../tpu/v1/internal/tpu_auth_decorator.cc | 48 ++ .../tpu/v1/internal/tpu_auth_decorator.h | 24 + .../tpu/v1/internal/tpu_connection_impl.cc | 115 ++++ .../tpu/v1/internal/tpu_connection_impl.h | 18 + .../tpu/v1/internal/tpu_logging_decorator.cc | 68 +++ .../tpu/v1/internal/tpu_logging_decorator.h | 24 + .../tpu/v1/internal/tpu_metadata_decorator.cc | 50 ++ .../tpu/v1/internal/tpu_metadata_decorator.h | 24 + google/cloud/tpu/v1/internal/tpu_stub.cc | 68 +++ google/cloud/tpu/v1/internal/tpu_stub.h | 63 ++- .../cloud/tpu/v1/internal/tpu_stub_factory.cc | 9 +- .../tpu/v1/internal/tpu_tracing_connection.cc | 48 ++ .../tpu/v1/internal/tpu_tracing_connection.h | 18 + .../cloud/tpu/v1/internal/tpu_tracing_stub.cc | 66 +++ .../cloud/tpu/v1/internal/tpu_tracing_stub.h | 24 + .../cloud/tpu/v1/mocks/mock_tpu_connection.h | 23 + google/cloud/tpu/v1/tpu_client.cc | 67 +++ google/cloud/tpu/v1/tpu_client.h | 350 +++++++++++++ google/cloud/tpu/v1/tpu_connection.cc | 34 ++ google/cloud/tpu/v1/tpu_connection.h | 18 + .../v1/tpu_connection_idempotency_policy.cc | 30 ++ .../v1/tpu_connection_idempotency_policy.h | 20 + .../tpu/v2/internal/tpu_auth_decorator.cc | 48 ++ .../tpu/v2/internal/tpu_auth_decorator.h | 24 + .../tpu/v2/internal/tpu_connection_impl.cc | 115 ++++ .../tpu/v2/internal/tpu_connection_impl.h | 18 + .../tpu/v2/internal/tpu_logging_decorator.cc | 68 +++ .../tpu/v2/internal/tpu_logging_decorator.h | 24 + .../tpu/v2/internal/tpu_metadata_decorator.cc | 50 ++ .../tpu/v2/internal/tpu_metadata_decorator.h | 24 + google/cloud/tpu/v2/internal/tpu_stub.cc | 68 +++ google/cloud/tpu/v2/internal/tpu_stub.h | 63 ++- .../cloud/tpu/v2/internal/tpu_stub_factory.cc | 9 +- .../tpu/v2/internal/tpu_tracing_connection.cc | 48 ++ .../tpu/v2/internal/tpu_tracing_connection.h | 18 + .../cloud/tpu/v2/internal/tpu_tracing_stub.cc | 66 +++ .../cloud/tpu/v2/internal/tpu_tracing_stub.h | 24 + .../cloud/tpu/v2/mocks/mock_tpu_connection.h | 23 + google/cloud/tpu/v2/tpu_client.cc | 67 +++ google/cloud/tpu/v2/tpu_client.h | 350 +++++++++++++ google/cloud/tpu/v2/tpu_connection.cc | 34 ++ google/cloud/tpu/v2/tpu_connection.h | 18 + .../v2/tpu_connection_idempotency_policy.cc | 30 ++ .../v2/tpu_connection_idempotency_policy.h | 20 + google/cloud/translate/BUILD.bazel | 2 + .../v3/internal/translation_auth_decorator.cc | 58 +++ .../v3/internal/translation_auth_decorator.h | 28 + .../internal/translation_connection_impl.cc | 135 +++++ .../v3/internal/translation_connection_impl.h | 21 + .../internal/translation_logging_decorator.cc | 82 +++ .../internal/translation_logging_decorator.h | 28 + .../translation_metadata_decorator.cc | 60 +++ .../internal/translation_metadata_decorator.h | 28 + .../translate/v3/internal/translation_stub.cc | 82 +++ .../translate/v3/internal/translation_stub.h | 71 ++- .../v3/internal/translation_stub_factory.cc | 9 +- .../translation_tracing_connection.cc | 65 +++ .../internal/translation_tracing_connection.h | 21 + .../v3/internal/translation_tracing_stub.cc | 82 +++ .../v3/internal/translation_tracing_stub.h | 28 + .../v3/mocks/mock_translation_connection.h | 27 + .../cloud/translate/v3/translation_client.cc | 81 +++ .../cloud/translate/v3/translation_client.h | 389 ++++++++++++++ .../translate/v3/translation_connection.cc | 44 ++ .../translate/v3/translation_connection.h | 21 + ...anslation_connection_idempotency_policy.cc | 35 ++ ...ranslation_connection_idempotency_policy.h | 23 + google/cloud/video/BUILD.bazel | 2 + .../v1/internal/livestream_auth_decorator.cc | 50 ++ .../v1/internal/livestream_auth_decorator.h | 24 + .../v1/internal/livestream_connection_impl.cc | 123 +++++ .../v1/internal/livestream_connection_impl.h | 18 + .../internal/livestream_logging_decorator.cc | 69 +++ .../internal/livestream_logging_decorator.h | 24 + .../internal/livestream_metadata_decorator.cc | 52 ++ .../internal/livestream_metadata_decorator.h | 24 + .../livestream/v1/internal/livestream_stub.cc | 70 +++ .../livestream/v1/internal/livestream_stub.h | 63 ++- .../v1/internal/livestream_stub_factory.cc | 9 +- .../internal/livestream_tracing_connection.cc | 56 ++ .../internal/livestream_tracing_connection.h | 18 + .../v1/internal/livestream_tracing_stub.cc | 70 +++ .../v1/internal/livestream_tracing_stub.h | 24 + .../video/livestream/v1/livestream_client.cc | 74 +++ .../video/livestream/v1/livestream_client.h | 350 +++++++++++++ .../livestream/v1/livestream_connection.cc | 38 ++ .../livestream/v1/livestream_connection.h | 18 + ...ivestream_connection_idempotency_policy.cc | 30 ++ ...livestream_connection_idempotency_policy.h | 20 + .../v1/mocks/mock_livestream_connection.h | 23 + .../internal/video_stitcher_auth_decorator.cc | 33 ++ .../internal/video_stitcher_auth_decorator.h | 16 + .../video_stitcher_connection_impl.cc | 74 +++ .../internal/video_stitcher_connection_impl.h | 12 + .../video_stitcher_logging_decorator.cc | 46 ++ .../video_stitcher_logging_decorator.h | 16 + .../video_stitcher_metadata_decorator.cc | 34 ++ .../video_stitcher_metadata_decorator.h | 16 + .../v1/internal/video_stitcher_stub.cc | 46 ++ .../v1/internal/video_stitcher_stub.h | 40 +- .../internal/video_stitcher_stub_factory.cc | 5 +- .../video_stitcher_tracing_connection.cc | 36 ++ .../video_stitcher_tracing_connection.h | 12 + .../internal/video_stitcher_tracing_stub.cc | 46 ++ .../v1/internal/video_stitcher_tracing_stub.h | 16 + .../v1/mocks/mock_video_stitcher_connection.h | 15 + .../stitcher/v1/video_stitcher_client.cc | 62 +++ .../video/stitcher/v1/video_stitcher_client.h | 280 ++++++++++ .../stitcher/v1/video_stitcher_connection.cc | 24 + .../stitcher/v1/video_stitcher_connection.h | 12 + ..._stitcher_connection_idempotency_policy.cc | 20 + ...o_stitcher_connection_idempotency_policy.h | 13 + .../cloud/vision/v1/image_annotator_client.cc | 14 + .../cloud/vision/v1/image_annotator_client.h | 60 +++ .../vision/v1/image_annotator_connection.cc | 5 + .../vision/v1/image_annotator_connection.h | 3 + ...annotator_connection_idempotency_policy.cc | 5 + ..._annotator_connection_idempotency_policy.h | 4 + .../image_annotator_auth_decorator.cc | 8 + .../internal/image_annotator_auth_decorator.h | 4 + .../image_annotator_connection_impl.cc | 14 + .../image_annotator_connection_impl.h | 3 + .../image_annotator_logging_decorator.cc | 11 + .../image_annotator_logging_decorator.h | 4 + .../image_annotator_metadata_decorator.cc | 8 + .../image_annotator_metadata_decorator.h | 4 + .../v1/internal/image_annotator_stub.cc | 12 + .../vision/v1/internal/image_annotator_stub.h | 16 +- .../internal/image_annotator_stub_factory.cc | 5 +- .../image_annotator_tracing_connection.cc | 9 + .../image_annotator_tracing_connection.h | 3 + .../internal/image_annotator_tracing_stub.cc | 12 + .../internal/image_annotator_tracing_stub.h | 4 + .../internal/product_search_auth_decorator.cc | 8 + .../internal/product_search_auth_decorator.h | 4 + .../product_search_connection_impl.cc | 14 + .../internal/product_search_connection_impl.h | 3 + .../product_search_logging_decorator.cc | 11 + .../product_search_logging_decorator.h | 4 + .../product_search_metadata_decorator.cc | 8 + .../product_search_metadata_decorator.h | 4 + .../vision/v1/internal/product_search_stub.cc | 11 + .../vision/v1/internal/product_search_stub.h | 16 +- .../internal/product_search_stub_factory.cc | 5 +- .../product_search_tracing_connection.cc | 9 + .../product_search_tracing_connection.h | 3 + .../internal/product_search_tracing_stub.cc | 11 + .../v1/internal/product_search_tracing_stub.h | 4 + .../mocks/mock_image_annotator_connection.h | 4 + .../v1/mocks/mock_product_search_connection.h | 4 + .../cloud/vision/v1/product_search_client.cc | 14 + .../cloud/vision/v1/product_search_client.h | 60 +++ .../vision/v1/product_search_connection.cc | 5 + .../vision/v1/product_search_connection.h | 3 + ...ct_search_connection_idempotency_policy.cc | 5 + ...uct_search_connection_idempotency_policy.h | 4 + google/cloud/vmmigration/BUILD.bazel | 2 + .../internal/vm_migration_auth_decorator.cc | 50 ++ .../v1/internal/vm_migration_auth_decorator.h | 24 + .../internal/vm_migration_connection_impl.cc | 121 +++++ .../internal/vm_migration_connection_impl.h | 18 + .../vm_migration_logging_decorator.cc | 68 +++ .../internal/vm_migration_logging_decorator.h | 24 + .../vm_migration_metadata_decorator.cc | 50 ++ .../vm_migration_metadata_decorator.h | 24 + .../v1/internal/vm_migration_stub.cc | 68 +++ .../v1/internal/vm_migration_stub.h | 63 ++- .../v1/internal/vm_migration_stub_factory.cc | 9 +- .../vm_migration_tracing_connection.cc | 56 ++ .../vm_migration_tracing_connection.h | 18 + .../v1/internal/vm_migration_tracing_stub.cc | 68 +++ .../v1/internal/vm_migration_tracing_stub.h | 24 + .../v1/mocks/mock_vm_migration_connection.h | 23 + .../vmmigration/v1/vm_migration_client.cc | 69 +++ .../vmmigration/v1/vm_migration_client.h | 350 +++++++++++++ .../vmmigration/v1/vm_migration_connection.cc | 36 ++ .../vmmigration/v1/vm_migration_connection.h | 18 + ...migration_connection_idempotency_policy.cc | 30 ++ ..._migration_connection_idempotency_policy.h | 20 + google/cloud/vmwareengine/BUILD.bazel | 2 + .../internal/vmware_engine_auth_decorator.cc | 67 +++ .../internal/vmware_engine_auth_decorator.h | 32 ++ .../internal/vmware_engine_connection_impl.cc | 148 ++++++ .../internal/vmware_engine_connection_impl.h | 24 + .../vmware_engine_logging_decorator.cc | 91 ++++ .../vmware_engine_logging_decorator.h | 32 ++ .../vmware_engine_metadata_decorator.cc | 70 +++ .../vmware_engine_metadata_decorator.h | 32 ++ .../v1/internal/vmware_engine_stub.cc | 93 ++++ .../v1/internal/vmware_engine_stub.h | 84 ++- .../v1/internal/vmware_engine_stub_factory.cc | 11 +- .../vmware_engine_tracing_connection.cc | 73 +++ .../vmware_engine_tracing_connection.h | 24 + .../v1/internal/vmware_engine_tracing_stub.cc | 92 ++++ .../v1/internal/vmware_engine_tracing_stub.h | 32 ++ .../v1/mocks/mock_vmware_engine_connection.h | 32 ++ .../vmwareengine/v1/vmware_engine_client.cc | 75 +++ .../vmwareengine/v1/vmware_engine_client.h | 379 ++++++++++++++ .../v1/vmware_engine_connection.cc | 47 ++ .../v1/vmware_engine_connection.h | 24 + ...re_engine_connection_idempotency_policy.cc | 41 ++ ...are_engine_connection_idempotency_policy.h | 27 + google/cloud/vpcaccess/BUILD.bazel | 2 + .../v1/internal/vpc_access_auth_decorator.cc | 26 + .../v1/internal/vpc_access_auth_decorator.h | 12 + .../v1/internal/vpc_access_connection_impl.cc | 81 +++ .../v1/internal/vpc_access_connection_impl.h | 9 + .../internal/vpc_access_logging_decorator.cc | 35 ++ .../internal/vpc_access_logging_decorator.h | 12 + .../internal/vpc_access_metadata_decorator.cc | 26 + .../internal/vpc_access_metadata_decorator.h | 12 + .../vpcaccess/v1/internal/vpc_access_stub.cc | 36 ++ .../vpcaccess/v1/internal/vpc_access_stub.h | 39 +- .../v1/internal/vpc_access_stub_factory.cc | 9 +- .../internal/vpc_access_tracing_connection.cc | 31 ++ .../internal/vpc_access_tracing_connection.h | 9 + .../v1/internal/vpc_access_tracing_stub.cc | 36 ++ .../v1/internal/vpc_access_tracing_stub.h | 12 + .../v1/mocks/mock_vpc_access_connection.h | 11 + .../cloud/vpcaccess/v1/vpc_access_client.cc | 39 ++ google/cloud/vpcaccess/v1/vpc_access_client.h | 191 +++++++ .../vpcaccess/v1/vpc_access_connection.cc | 22 + .../vpcaccess/v1/vpc_access_connection.h | 9 + ...pc_access_connection_idempotency_policy.cc | 15 + ...vpc_access_connection_idempotency_policy.h | 11 + .../v1/internal/web_risk_auth_decorator.cc | 33 ++ .../v1/internal/web_risk_auth_decorator.h | 16 + .../v1/internal/web_risk_connection_impl.cc | 74 +++ .../v1/internal/web_risk_connection_impl.h | 13 + .../v1/internal/web_risk_logging_decorator.cc | 45 ++ .../v1/internal/web_risk_logging_decorator.h | 16 + .../internal/web_risk_metadata_decorator.cc | 33 ++ .../v1/internal/web_risk_metadata_decorator.h | 16 + .../webrisk/v1/internal/web_risk_stub.cc | 46 ++ .../cloud/webrisk/v1/internal/web_risk_stub.h | 40 +- .../v1/internal/web_risk_stub_factory.cc | 5 +- .../internal/web_risk_tracing_connection.cc | 37 ++ .../v1/internal/web_risk_tracing_connection.h | 12 + .../v1/internal/web_risk_tracing_stub.cc | 46 ++ .../v1/internal/web_risk_tracing_stub.h | 16 + .../v1/mocks/mock_web_risk_connection.h | 15 + google/cloud/webrisk/v1/web_risk_client.cc | 59 +++ google/cloud/webrisk/v1/web_risk_client.h | 280 ++++++++++ .../cloud/webrisk/v1/web_risk_connection.cc | 24 + google/cloud/webrisk/v1/web_risk_connection.h | 13 + .../web_risk_connection_idempotency_policy.cc | 20 + .../web_risk_connection_idempotency_policy.h | 13 + google/cloud/workflows/BUILD.bazel | 2 + .../v1/internal/workflows_auth_decorator.cc | 42 ++ .../v1/internal/workflows_auth_decorator.h | 20 + .../v1/internal/workflows_connection_impl.cc | 107 ++++ .../v1/internal/workflows_connection_impl.h | 15 + .../internal/workflows_logging_decorator.cc | 57 ++ .../v1/internal/workflows_logging_decorator.h | 20 + .../internal/workflows_metadata_decorator.cc | 42 ++ .../internal/workflows_metadata_decorator.h | 20 + .../workflows/v1/internal/workflows_stub.cc | 57 ++ .../workflows/v1/internal/workflows_stub.h | 55 +- .../v1/internal/workflows_stub_factory.cc | 9 +- .../internal/workflows_tracing_connection.cc | 48 ++ .../internal/workflows_tracing_connection.h | 15 + .../v1/internal/workflows_tracing_stub.cc | 57 ++ .../v1/internal/workflows_tracing_stub.h | 20 + .../v1/mocks/mock_workflows_connection.h | 19 + google/cloud/workflows/v1/workflows_client.cc | 54 ++ google/cloud/workflows/v1/workflows_client.h | 277 ++++++++++ .../workflows/v1/workflows_connection.cc | 30 ++ .../cloud/workflows/v1/workflows_connection.h | 15 + ...workflows_connection_idempotency_policy.cc | 25 + .../workflows_connection_idempotency_policy.h | 17 + google/cloud/workstations/BUILD.bazel | 2 + .../internal/workstations_auth_decorator.cc | 58 +++ .../v1/internal/workstations_auth_decorator.h | 28 + .../internal/workstations_connection_impl.cc | 113 ++++ .../internal/workstations_connection_impl.h | 21 + .../workstations_logging_decorator.cc | 79 +++ .../internal/workstations_logging_decorator.h | 28 + .../workstations_metadata_decorator.cc | 61 +++ .../workstations_metadata_decorator.h | 28 + .../v1/internal/workstations_stub.cc | 80 +++ .../v1/internal/workstations_stub.h | 69 ++- .../v1/internal/workstations_stub_factory.cc | 8 +- .../workstations_tracing_connection.cc | 61 +++ .../workstations_tracing_connection.h | 21 + .../v1/internal/workstations_tracing_stub.cc | 79 +++ .../v1/internal/workstations_tracing_stub.h | 28 + .../v1/mocks/mock_workstations_connection.h | 28 + .../workstations/v1/workstations_client.cc | 76 +++ .../workstations/v1/workstations_client.h | 382 ++++++++++++++ .../v1/workstations_connection.cc | 39 ++ .../workstations/v1/workstations_connection.h | 21 + ...kstations_connection_idempotency_policy.cc | 36 ++ ...rkstations_connection_idempotency_policy.h | 23 + 5205 files changed, 243003 insertions(+), 569 deletions(-) diff --git a/generator/internal/make_generators.cc b/generator/internal/make_generators.cc index 1cc109193e731..3aec7bca48bff 100644 --- a/generator/internal/make_generators.cc +++ b/generator/internal/make_generators.cc @@ -61,7 +61,8 @@ std::vector> MakeGenerators( YAML::Node const& service_config, std::vector> const& vars) { std::vector mixin_methods; - if (service->name() == "DataMigrationService") { + if (service->file()->name() != "google/pubsub/v1/pubsub.proto" && + service->file()->name() != "google/pubsub/v1/schema.proto") { mixin_methods = GetMixinMethods(service_config, *service); if (!mixin_methods.empty()) { std::cout << "###########################################" @@ -87,17 +88,6 @@ std::vector> MakeGenerators( CreateServiceVars(*service, vars, mixin_methods); auto method_vars = CreateMethodVars(*service, service_config, service_vars, mixin_methods); - if (service->name() == "DataMigrationService") { - std::cout << "###########################################@@" << std::endl; - for (auto& x : method_vars) { - if (x.first != "google.longrunning.Operations.GetOperation") continue; - - std::cout << x.first << " : " << x.second["response_type"] << " : " - << x.second["return_type"] << " : " - << x.second["longrunning_deduced_response_type"] << std::endl; - } - std::cout << "###########################################@@" << std::endl; - } 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; diff --git a/google/cloud/accesscontextmanager/v1/access_context_manager_client.cc b/google/cloud/accesscontextmanager/v1/access_context_manager_client.cc index 21c097e4d48f6..8a1d53820645a 100644 --- a/google/cloud/accesscontextmanager/v1/access_context_manager_client.cc +++ b/google/cloud/accesscontextmanager/v1/access_context_manager_client.cc @@ -861,6 +861,22 @@ AccessContextManagerClient::TestIamPermissions( return connection_->TestIamPermissions(request); } +StatusOr +AccessContextManagerClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +AccessContextManagerClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace accesscontextmanager_v1 } // namespace cloud diff --git a/google/cloud/accesscontextmanager/v1/access_context_manager_client.h b/google/cloud/accesscontextmanager/v1/access_context_manager_client.h index 32a52e5c3e29e..78a51dcb940bc 100644 --- a/google/cloud/accesscontextmanager/v1/access_context_manager_client.h +++ b/google/cloud/accesscontextmanager/v1/access_context_manager_client.h @@ -2575,6 +2575,66 @@ class AccessContextManagerClient { google::iam::v1::TestIamPermissionsRequest const& request, Options opts = {}); + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/accesscontextmanager/v1/access_context_manager_connection.cc b/google/cloud/accesscontextmanager/v1/access_context_manager_connection.cc index bc9ccb0ea1fb6..a991e6b7bd5f0 100644 --- a/google/cloud/accesscontextmanager/v1/access_context_manager_connection.cc +++ b/google/cloud/accesscontextmanager/v1/access_context_manager_connection.cc @@ -516,6 +516,12 @@ AccessContextManagerConnection::TestIamPermissions( return Status(StatusCode::kUnimplemented, "not implemented"); } +StatusOr +AccessContextManagerConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeAccessContextManagerConnection(Options options) { internal::CheckExpectedOptions TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/accesscontextmanager/v1/access_context_manager_connection_idempotency_policy.cc b/google/cloud/accesscontextmanager/v1/access_context_manager_connection_idempotency_policy.cc index 3374bb6a90c91..1affb8ecc7585 100644 --- a/google/cloud/accesscontextmanager/v1/access_context_manager_connection_idempotency_policy.cc +++ b/google/cloud/accesscontextmanager/v1/access_context_manager_connection_idempotency_policy.cc @@ -199,6 +199,11 @@ Idempotency AccessContextManagerConnectionIdempotencyPolicy::TestIamPermissions( return Idempotency::kIdempotent; } +Idempotency AccessContextManagerConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultAccessContextManagerConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/accesscontextmanager/v1/access_context_manager_connection_idempotency_policy.h b/google/cloud/accesscontextmanager/v1/access_context_manager_connection_idempotency_policy.h index 925f7243b74e5..0eb739ac779b5 100644 --- a/google/cloud/accesscontextmanager/v1/access_context_manager_connection_idempotency_policy.h +++ b/google/cloud/accesscontextmanager/v1/access_context_manager_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -136,6 +137,9 @@ class AccessContextManagerConnectionIdempotencyPolicy { virtual google::cloud::Idempotency TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_auth_decorator.cc b/google/cloud/accesscontextmanager/v1/internal/access_context_manager_auth_decorator.cc index d78546d34b48d..dc864544f7a97 100644 --- a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_auth_decorator.cc +++ b/google/cloud/accesscontextmanager/v1/internal/access_context_manager_auth_decorator.cc @@ -601,6 +601,14 @@ AccessContextManagerAuth::TestIamPermissions( return child_->TestIamPermissions(context, options, request); } +StatusOr AccessContextManagerAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + future> AccessContextManagerAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_auth_decorator.h b/google/cloud/accesscontextmanager/v1/internal/access_context_manager_auth_decorator.h index 0157b10a38d26..efde008bcff0c 100644 --- a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_auth_decorator.h +++ b/google/cloud/accesscontextmanager/v1/internal/access_context_manager_auth_decorator.h @@ -284,6 +284,10 @@ class AccessContextManagerAuth : public AccessContextManagerStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_connection_impl.cc b/google/cloud/accesscontextmanager/v1/internal/access_context_manager_connection_impl.cc index 1d3a5a57056c2..1f6b3328a64b7 100644 --- a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_connection_impl.cc +++ b/google/cloud/accesscontextmanager/v1/internal/access_context_manager_connection_impl.cc @@ -1796,6 +1796,20 @@ AccessContextManagerConnectionImpl::TestIamPermissions( *current, request, __func__); } +StatusOr +AccessContextManagerConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace accesscontextmanager_v1_internal } // namespace cloud diff --git a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_connection_impl.h b/google/cloud/accesscontextmanager/v1/internal/access_context_manager_connection_impl.h index f77f295105be8..f3ca0294e700f 100644 --- a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_connection_impl.h +++ b/google/cloud/accesscontextmanager/v1/internal/access_context_manager_connection_impl.h @@ -306,6 +306,9 @@ class AccessContextManagerConnectionImpl StatusOr TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr diff --git a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_logging_decorator.cc b/google/cloud/accesscontextmanager/v1/internal/access_context_manager_logging_decorator.cc index 1c0876970a74c..3db37e0e4e9dd 100644 --- a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_logging_decorator.cc +++ b/google/cloud/accesscontextmanager/v1/internal/access_context_manager_logging_decorator.cc @@ -691,6 +691,18 @@ AccessContextManagerLogging::TestIamPermissions( context, options, request, __func__, tracing_options_); } +StatusOr +AccessContextManagerLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> AccessContextManagerLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_logging_decorator.h b/google/cloud/accesscontextmanager/v1/internal/access_context_manager_logging_decorator.h index 9a42ede1e3a7f..8e68588e6df28 100644 --- a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_logging_decorator.h +++ b/google/cloud/accesscontextmanager/v1/internal/access_context_manager_logging_decorator.h @@ -284,6 +284,10 @@ class AccessContextManagerLogging : public AccessContextManagerStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_metadata_decorator.cc b/google/cloud/accesscontextmanager/v1/internal/access_context_manager_metadata_decorator.cc index 5fa97c80782d9..2a22436194ac8 100644 --- a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_metadata_decorator.cc +++ b/google/cloud/accesscontextmanager/v1/internal/access_context_manager_metadata_decorator.cc @@ -506,6 +506,15 @@ AccessContextManagerMetadata::TestIamPermissions( return child_->TestIamPermissions(context, options, request); } +StatusOr +AccessContextManagerMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + future> AccessContextManagerMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_metadata_decorator.h b/google/cloud/accesscontextmanager/v1/internal/access_context_manager_metadata_decorator.h index d6bb2888a3907..f994cd011d061 100644 --- a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_metadata_decorator.h +++ b/google/cloud/accesscontextmanager/v1/internal/access_context_manager_metadata_decorator.h @@ -285,6 +285,10 @@ class AccessContextManagerMetadata : public AccessContextManagerStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_stub.cc b/google/cloud/accesscontextmanager/v1/internal/access_context_manager_stub.cc index f0c2701f558c4..a7ca6fdf94952 100644 --- a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_stub.cc +++ b/google/cloud/accesscontextmanager/v1/internal/access_context_manager_stub.cc @@ -680,6 +680,18 @@ DefaultAccessContextManagerStub::TestIamPermissions( return response; } +StatusOr +DefaultAccessContextManagerStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultAccessContextManagerStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_stub.h b/google/cloud/accesscontextmanager/v1/internal/access_context_manager_stub.h index fc8e8ea9fd18b..937e6e4a8274d 100644 --- a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_stub.h +++ b/google/cloud/accesscontextmanager/v1/internal/access_context_manager_stub.h @@ -290,6 +290,10 @@ class AccessContextManagerStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -309,9 +313,13 @@ class DefaultAccessContextManagerStub : public AccessContextManagerStub { std::unique_ptr grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr< google::identity::accesscontextmanager::v1::ListAccessPoliciesResponse> @@ -558,6 +566,10 @@ class DefaultAccessContextManagerStub : public AccessContextManagerStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -574,6 +586,8 @@ class DefaultAccessContextManagerStub : public AccessContextManagerStub { std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_stub_factory.cc b/google/cloud/accesscontextmanager/v1/internal/access_context_manager_stub_factory.cc index 1850442c75aea..3857c3c272ce2 100644 --- a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_stub_factory.cc +++ b/google/cloud/accesscontextmanager/v1/internal/access_context_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 CreateDefaultAccessContextManagerStub( auto service_grpc_stub = google::identity::accesscontextmanager::v1::AccessContextManager::NewStub( channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_tracing_connection.cc b/google/cloud/accesscontextmanager/v1/internal/access_context_manager_tracing_connection.cc index 8baacb850a43f..f5235aea2932f 100644 --- a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_tracing_connection.cc +++ b/google/cloud/accesscontextmanager/v1/internal/access_context_manager_tracing_connection.cc @@ -706,6 +706,15 @@ AccessContextManagerTracingConnection::TestIamPermissions( return internal::EndSpan(*span, child_->TestIamPermissions(request)); } +StatusOr +AccessContextManagerTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "accesscontextmanager_v1::AccessContextManagerConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_tracing_connection.h b/google/cloud/accesscontextmanager/v1/internal/access_context_manager_tracing_connection.h index 77349de793ed7..1145661c6db1a 100644 --- a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_tracing_connection.h +++ b/google/cloud/accesscontextmanager/v1/internal/access_context_manager_tracing_connection.h @@ -293,6 +293,9 @@ class AccessContextManagerTracingConnection StatusOr TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; diff --git a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_tracing_stub.cc b/google/cloud/accesscontextmanager/v1/internal/access_context_manager_tracing_stub.cc index ad065eaec0ed2..84fdea8249754 100644 --- a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_tracing_stub.cc +++ b/google/cloud/accesscontextmanager/v1/internal/access_context_manager_tracing_stub.cc @@ -656,6 +656,19 @@ AccessContextManagerTracingStub::TestIamPermissions( context, *span, child_->TestIamPermissions(context, options, request)); } +StatusOr +AccessContextManagerTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.identity.accesscontextmanager.v1.AccessContextManager", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + future> AccessContextManagerTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_tracing_stub.h b/google/cloud/accesscontextmanager/v1/internal/access_context_manager_tracing_stub.h index 3d0192f5206fd..02c1e1c5aed72 100644 --- a/google/cloud/accesscontextmanager/v1/internal/access_context_manager_tracing_stub.h +++ b/google/cloud/accesscontextmanager/v1/internal/access_context_manager_tracing_stub.h @@ -284,6 +284,10 @@ class AccessContextManagerTracingStub : public AccessContextManagerStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/accesscontextmanager/v1/mocks/mock_access_context_manager_connection.h b/google/cloud/accesscontextmanager/v1/mocks/mock_access_context_manager_connection.h index 9a6226da6fa5c..087d30e22d0ac 100644 --- a/google/cloud/accesscontextmanager/v1/mocks/mock_access_context_manager_connection.h +++ b/google/cloud/accesscontextmanager/v1/mocks/mock_access_context_manager_connection.h @@ -742,6 +742,10 @@ class MockAccessContextManagerConnection TestIamPermissions, (google::iam::v1::TestIamPermissionsRequest const& request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END 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..777a77854ea29 100644 --- a/google/cloud/aiplatform/v1/dataset_client.cc +++ b/google/cloud/aiplatform/v1/dataset_client.cc @@ -554,6 +554,103 @@ 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); +} + +StreamRange +DatasetServiceClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +DatasetServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr DatasetServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr DatasetServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status DatasetServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status DatasetServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status DatasetServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status DatasetServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +StatusOr DatasetServiceClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(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 cc0d82d977146..24d640bacdd1d 100644 --- a/google/cloud/aiplatform/v1/dataset_client.h +++ b/google/cloud/aiplatform/v1/dataset_client.h @@ -1758,6 +1758,497 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..7d15c3b8134b8 100644 --- a/google/cloud/aiplatform/v1/dataset_connection.cc +++ b/google/cloud/aiplatform/v1/dataset_connection.cc @@ -297,6 +297,65 @@ 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"); +} + +StreamRange +DatasetServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr DatasetServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DatasetServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DatasetServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +DatasetServiceConnection::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDatasetServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..f2bcbc47c1b06 100644 --- a/google/cloud/aiplatform/v1/dataset_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/dataset_connection_idempotency_policy.cc @@ -129,6 +129,57 @@ 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; +} + +Idempotency DatasetServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DatasetServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DatasetServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency DatasetServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency DatasetServiceConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..3f5f321d02bc0 100644 --- a/google/cloud/aiplatform/v1/dataset_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/dataset_connection_idempotency_policy.h @@ -22,6 +22,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -97,6 +100,36 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest 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..ed8d0df861418 100644 --- a/google/cloud/aiplatform/v1/deployment_resource_pool_client.cc +++ b/google/cloud/aiplatform/v1/deployment_resource_pool_client.cc @@ -218,6 +218,110 @@ 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); +} + +StreamRange +DeploymentResourcePoolServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +DeploymentResourcePoolServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +DeploymentResourcePoolServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +DeploymentResourcePoolServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status DeploymentResourcePoolServiceClient::DeleteOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status DeploymentResourcePoolServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status DeploymentResourcePoolServiceClient::CancelOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status DeploymentResourcePoolServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +StatusOr +DeploymentResourcePoolServiceClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(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..37719a6fa0e5d 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,497 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..d518cec327228 100644 --- a/google/cloud/aiplatform/v1/deployment_resource_pool_connection.cc +++ b/google/cloud/aiplatform/v1/deployment_resource_pool_connection.cc @@ -125,6 +125,68 @@ 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"); +} + +StreamRange +DeploymentResourcePoolServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +DeploymentResourcePoolServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DeploymentResourcePoolServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DeploymentResourcePoolServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +DeploymentResourcePoolServiceConnection::WaitOperation( + google::longrunning::WaitOperationRequest 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..eaa455f09821b 100644 --- a/google/cloud/aiplatform/v1/deployment_resource_pool_connection.h +++ b/google/cloud/aiplatform/v1/deployment_resource_pool_connection.h @@ -259,6 +259,36 @@ 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..3d7b2599fcc75 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,67 @@ 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; +} + +Idempotency +DeploymentResourcePoolServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency +DeploymentResourcePoolServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +DeploymentResourcePoolServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency +DeploymentResourcePoolServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency +DeploymentResourcePoolServiceConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..b82c38b14afd8 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,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -57,6 +60,36 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest 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..cf7a09176dd31 100644 --- a/google/cloud/aiplatform/v1/endpoint_client.cc +++ b/google/cloud/aiplatform/v1/endpoint_client.cc @@ -339,6 +339,103 @@ 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); +} + +StreamRange +EndpointServiceClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +EndpointServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr EndpointServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr EndpointServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status EndpointServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status EndpointServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status EndpointServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status EndpointServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +StatusOr EndpointServiceClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(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..a41813d445ad8 100644 --- a/google/cloud/aiplatform/v1/endpoint_client.h +++ b/google/cloud/aiplatform/v1/endpoint_client.h @@ -1001,6 +1001,497 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..609975e449ba2 100644 --- a/google/cloud/aiplatform/v1/endpoint_connection.cc +++ b/google/cloud/aiplatform/v1/endpoint_connection.cc @@ -172,6 +172,66 @@ 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"); +} + +StreamRange +EndpointServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +EndpointServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status EndpointServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status EndpointServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +EndpointServiceConnection::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeEndpointServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions> 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..bf4f83fd98a14 100644 --- a/google/cloud/aiplatform/v1/endpoint_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/endpoint_connection_idempotency_policy.cc @@ -74,6 +74,57 @@ 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; +} + +Idempotency EndpointServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency EndpointServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency EndpointServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency EndpointServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency EndpointServiceConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..44ed6a344c117 100644 --- a/google/cloud/aiplatform/v1/endpoint_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/endpoint_connection_idempotency_policy.h @@ -22,6 +22,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -60,6 +63,36 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest 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..dd2fb213a779c 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,110 @@ 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); +} + +StreamRange +FeatureOnlineStoreAdminServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +FeatureOnlineStoreAdminServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +FeatureOnlineStoreAdminServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +FeatureOnlineStoreAdminServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status FeatureOnlineStoreAdminServiceClient::DeleteOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status FeatureOnlineStoreAdminServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status FeatureOnlineStoreAdminServiceClient::CancelOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status FeatureOnlineStoreAdminServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +StatusOr +FeatureOnlineStoreAdminServiceClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(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..5b3996c61f81a 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,497 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..2dcc725459a92 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,68 @@ 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"); +} + +StreamRange +FeatureOnlineStoreAdminServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +FeatureOnlineStoreAdminServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status FeatureOnlineStoreAdminServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status FeatureOnlineStoreAdminServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +FeatureOnlineStoreAdminServiceConnection::WaitOperation( + google::longrunning::WaitOperationRequest 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..0ca95936cfb94 100644 --- a/google/cloud/aiplatform/v1/feature_online_store_admin_connection.h +++ b/google/cloud/aiplatform/v1/feature_online_store_admin_connection.h @@ -308,6 +308,36 @@ 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..95d9091404bbf 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,67 @@ 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; +} + +Idempotency +FeatureOnlineStoreAdminServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency +FeatureOnlineStoreAdminServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +FeatureOnlineStoreAdminServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency +FeatureOnlineStoreAdminServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency +FeatureOnlineStoreAdminServiceConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..40edb0049b4ec 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,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -80,6 +83,36 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest 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..0ab1f55ee9b5b 100644 --- a/google/cloud/aiplatform/v1/feature_online_store_client.cc +++ b/google/cloud/aiplatform/v1/feature_online_store_client.cc @@ -61,6 +61,108 @@ 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); +} + +StreamRange +FeatureOnlineStoreServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +FeatureOnlineStoreServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +FeatureOnlineStoreServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +FeatureOnlineStoreServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status FeatureOnlineStoreServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status FeatureOnlineStoreServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status FeatureOnlineStoreServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status FeatureOnlineStoreServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +StatusOr +FeatureOnlineStoreServiceClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(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..ce8a9675a6e34 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,497 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..b2425c367ee20 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,68 @@ 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"); +} + +StreamRange +FeatureOnlineStoreServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +FeatureOnlineStoreServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status FeatureOnlineStoreServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status FeatureOnlineStoreServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +FeatureOnlineStoreServiceConnection::WaitOperation( + google::longrunning::WaitOperationRequest 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..1a278b6b727ea 100644 --- a/google/cloud/aiplatform/v1/feature_online_store_connection.h +++ b/google/cloud/aiplatform/v1/feature_online_store_connection.h @@ -25,6 +25,7 @@ #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 @@ -204,6 +205,36 @@ 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..5bc1d2abfb7b3 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,61 @@ 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; +} + +Idempotency +FeatureOnlineStoreServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency FeatureOnlineStoreServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +FeatureOnlineStoreServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency +FeatureOnlineStoreServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency FeatureOnlineStoreServiceConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..54db5fe88aa96 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,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -43,6 +46,36 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest 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..4203c4d232073 100644 --- a/google/cloud/aiplatform/v1/feature_registry_client.cc +++ b/google/cloud/aiplatform/v1/feature_registry_client.cc @@ -379,6 +379,108 @@ 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); +} + +StreamRange +FeatureRegistryServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +FeatureRegistryServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +FeatureRegistryServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +FeatureRegistryServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status FeatureRegistryServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status FeatureRegistryServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status FeatureRegistryServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status FeatureRegistryServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +StatusOr +FeatureRegistryServiceClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(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..55f3eefdb6184 100644 --- a/google/cloud/aiplatform/v1/feature_registry_client.h +++ b/google/cloud/aiplatform/v1/feature_registry_client.h @@ -1121,6 +1121,497 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..5221fbd53aa7f 100644 --- a/google/cloud/aiplatform/v1/feature_registry_connection.cc +++ b/google/cloud/aiplatform/v1/feature_registry_connection.cc @@ -207,6 +207,68 @@ 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"); +} + +StreamRange +FeatureRegistryServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +FeatureRegistryServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status FeatureRegistryServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status FeatureRegistryServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +FeatureRegistryServiceConnection::WaitOperation( + google::longrunning::WaitOperationRequest 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..064ca629ef44d 100644 --- a/google/cloud/aiplatform/v1/feature_registry_connection.h +++ b/google/cloud/aiplatform/v1/feature_registry_connection.h @@ -275,6 +275,36 @@ 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..5f87ebf9b633d 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,58 @@ 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; +} + +Idempotency FeatureRegistryServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency FeatureRegistryServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency FeatureRegistryServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency FeatureRegistryServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency FeatureRegistryServiceConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..7499ffaabab32 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,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -66,6 +69,36 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest 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..2b38c7db9ebc8 100644 --- a/google/cloud/aiplatform/v1/featurestore_client.cc +++ b/google/cloud/aiplatform/v1/featurestore_client.cc @@ -853,6 +853,107 @@ 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); +} + +StreamRange +FeaturestoreServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +FeaturestoreServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +FeaturestoreServiceClient::GetOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +FeaturestoreServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status FeaturestoreServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status FeaturestoreServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status FeaturestoreServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status FeaturestoreServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +StatusOr +FeaturestoreServiceClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(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..674ab4f0d1508 100644 --- a/google/cloud/aiplatform/v1/featurestore_client.h +++ b/google/cloud/aiplatform/v1/featurestore_client.h @@ -2561,6 +2561,497 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..bdc7d4660b598 100644 --- a/google/cloud/aiplatform/v1/featurestore_connection.cc +++ b/google/cloud/aiplatform/v1/featurestore_connection.cc @@ -384,6 +384,66 @@ 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"); +} + +StreamRange +FeaturestoreServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +FeaturestoreServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status FeaturestoreServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status FeaturestoreServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +FeaturestoreServiceConnection::WaitOperation( + google::longrunning::WaitOperationRequest 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..ce0d529a4f648 100644 --- a/google/cloud/aiplatform/v1/featurestore_connection.h +++ b/google/cloud/aiplatform/v1/featurestore_connection.h @@ -368,6 +368,36 @@ 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..7880f004614dd 100644 --- a/google/cloud/aiplatform/v1/featurestore_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/featurestore_connection_idempotency_policy.cc @@ -141,6 +141,57 @@ 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; +} + +Idempotency FeaturestoreServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency FeaturestoreServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency FeaturestoreServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency FeaturestoreServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency FeaturestoreServiceConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..b68cf26714780 100644 --- a/google/cloud/aiplatform/v1/featurestore_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/featurestore_connection_idempotency_policy.h @@ -22,6 +22,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -100,6 +103,36 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest 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..7ab2924e3727f 100644 --- a/google/cloud/aiplatform/v1/featurestore_online_serving_client.cc +++ b/google/cloud/aiplatform/v1/featurestore_online_serving_client.cc @@ -90,6 +90,109 @@ 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); +} + +StreamRange +FeaturestoreOnlineServingServiceClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +FeaturestoreOnlineServingServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +FeaturestoreOnlineServingServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +FeaturestoreOnlineServingServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status FeaturestoreOnlineServingServiceClient::DeleteOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status FeaturestoreOnlineServingServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status FeaturestoreOnlineServingServiceClient::CancelOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status FeaturestoreOnlineServingServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +StatusOr +FeaturestoreOnlineServingServiceClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(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..95df0df2fb807 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,497 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..c24df7aaedae7 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,68 @@ 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"); +} + +StreamRange +FeaturestoreOnlineServingServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +FeaturestoreOnlineServingServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status FeaturestoreOnlineServingServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status FeaturestoreOnlineServingServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +FeaturestoreOnlineServingServiceConnection::WaitOperation( + google::longrunning::WaitOperationRequest 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..d6c2c69a520f6 100644 --- a/google/cloud/aiplatform/v1/featurestore_online_serving_connection.h +++ b/google/cloud/aiplatform/v1/featurestore_online_serving_connection.h @@ -215,6 +215,36 @@ 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..a0a85bcfe42ff 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,67 @@ 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; +} + +Idempotency +FeaturestoreOnlineServingServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency +FeaturestoreOnlineServingServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +FeaturestoreOnlineServingServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency +FeaturestoreOnlineServingServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency +FeaturestoreOnlineServingServiceConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..27261454e4971 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,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -43,6 +46,36 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest 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..3b0e6d651241c 100644 --- a/google/cloud/aiplatform/v1/gen_ai_tuning_client.cc +++ b/google/cloud/aiplatform/v1/gen_ai_tuning_client.cc @@ -99,6 +99,106 @@ 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); +} + +StreamRange +GenAiTuningServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +GenAiTuningServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr GenAiTuningServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr GenAiTuningServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status GenAiTuningServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status GenAiTuningServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status GenAiTuningServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status GenAiTuningServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +StatusOr +GenAiTuningServiceClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(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..623804cbf6371 100644 --- a/google/cloud/aiplatform/v1/gen_ai_tuning_client.h +++ b/google/cloud/aiplatform/v1/gen_ai_tuning_client.h @@ -362,6 +362,497 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..23fef9f1657f8 100644 --- a/google/cloud/aiplatform/v1/gen_ai_tuning_connection.cc +++ b/google/cloud/aiplatform/v1/gen_ai_tuning_connection.cc @@ -63,6 +63,66 @@ 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"); +} + +StreamRange +GenAiTuningServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +GenAiTuningServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status GenAiTuningServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status GenAiTuningServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +GenAiTuningServiceConnection::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeGenAiTuningServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..c8f0badea31ef 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,57 @@ 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; +} + +Idempotency GenAiTuningServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency GenAiTuningServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency GenAiTuningServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency GenAiTuningServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency GenAiTuningServiceConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..1b932f43051b6 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,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -48,6 +51,36 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest 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..9d219c5b858b5 100644 --- a/google/cloud/aiplatform/v1/index_client.cc +++ b/google/cloud/aiplatform/v1/index_client.cc @@ -205,6 +205,101 @@ 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); +} + +StreamRange IndexServiceClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange IndexServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr IndexServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr IndexServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status IndexServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status IndexServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status IndexServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status IndexServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +StatusOr IndexServiceClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(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..d1f5b2d395a93 100644 --- a/google/cloud/aiplatform/v1/index_client.h +++ b/google/cloud/aiplatform/v1/index_client.h @@ -643,6 +643,497 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..aeb50aacb2077 100644 --- a/google/cloud/aiplatform/v1/index_connection.cc +++ b/google/cloud/aiplatform/v1/index_connection.cc @@ -126,6 +126,63 @@ 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"); +} + +StreamRange +IndexServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr IndexServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status IndexServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status IndexServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr IndexServiceConnection::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeIndexServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..8b38d32a6aefa 100644 --- a/google/cloud/aiplatform/v1/index_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/index_connection_idempotency_policy.cc @@ -69,6 +69,57 @@ 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; +} + +Idempotency IndexServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency IndexServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency IndexServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency IndexServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency IndexServiceConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..2d6a4a9f33f24 100644 --- a/google/cloud/aiplatform/v1/index_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/index_connection_idempotency_policy.h @@ -22,6 +22,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -57,6 +60,36 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest 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..d896bca2f8546 100644 --- a/google/cloud/aiplatform/v1/index_endpoint_client.cc +++ b/google/cloud/aiplatform/v1/index_endpoint_client.cc @@ -319,6 +319,108 @@ 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); +} + +StreamRange +IndexEndpointServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +IndexEndpointServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +IndexEndpointServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +IndexEndpointServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status IndexEndpointServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status IndexEndpointServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status IndexEndpointServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status IndexEndpointServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +StatusOr +IndexEndpointServiceClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(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..338b47a554f50 100644 --- a/google/cloud/aiplatform/v1/index_endpoint_client.h +++ b/google/cloud/aiplatform/v1/index_endpoint_client.h @@ -891,6 +891,497 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..1440873ec45ac 100644 --- a/google/cloud/aiplatform/v1/index_endpoint_connection.cc +++ b/google/cloud/aiplatform/v1/index_endpoint_connection.cc @@ -176,6 +176,66 @@ 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"); +} + +StreamRange +IndexEndpointServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +IndexEndpointServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status IndexEndpointServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status IndexEndpointServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +IndexEndpointServiceConnection::WaitOperation( + google::longrunning::WaitOperationRequest 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..667f0e461cfb5 100644 --- a/google/cloud/aiplatform/v1/index_endpoint_connection.h +++ b/google/cloud/aiplatform/v1/index_endpoint_connection.h @@ -260,6 +260,36 @@ 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..966ad2214815b 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,57 @@ 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; +} + +Idempotency IndexEndpointServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency IndexEndpointServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency IndexEndpointServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency IndexEndpointServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency IndexEndpointServiceConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..85c76ee774687 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,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -60,6 +63,36 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest 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..ad1a80e259ac7 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/dataset_auth_decorator.cc @@ -358,6 +358,89 @@ 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); +} + +StatusOr +DatasetServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr DatasetServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status DatasetServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status DatasetServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +StatusOr DatasetServiceAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(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..83b88efb15374 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/dataset_auth_decorator.h @@ -186,6 +186,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..367f2802b85b2 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/dataset_connection_impl.cc @@ -1092,6 +1092,181 @@ 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__); +} + +StreamRange +DatasetServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DatasetServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DatasetServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DatasetServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +DatasetServiceConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(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..d8ad53b542c98 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/dataset_connection_impl.h @@ -190,6 +190,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..d5dcc11797295 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/dataset_logging_decorator.cc @@ -427,6 +427,119 @@ 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_); +} + +StatusOr +DatasetServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DatasetServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DatasetServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DatasetServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DatasetServiceLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(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..19a4f110e9b28 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/dataset_logging_decorator.h @@ -186,6 +186,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..53a4dc71a767b 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/dataset_metadata_decorator.cc @@ -312,6 +312,91 @@ 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); +} + +StatusOr +DatasetServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr DatasetServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status DatasetServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status DatasetServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +StatusOr DatasetServiceMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(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..67f613312af82 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/dataset_metadata_decorator.h @@ -186,6 +186,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..6cddb0097f9d3 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_stub.cc +++ b/google/cloud/aiplatform/v1/internal/dataset_stub.cc @@ -407,6 +407,123 @@ 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; +} + +StatusOr +DefaultDatasetServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDatasetServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultDatasetServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultDatasetServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultDatasetServiceStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&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..fbb545bfb0e52 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_stub.h +++ b/google/cloud/aiplatform/v1/internal/dataset_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -187,6 +189,48 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -206,9 +250,18 @@ class DefaultDatasetServiceStub : public DatasetServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::DatasetService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +410,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -372,6 +465,11 @@ class DefaultDatasetServiceStub : public DatasetServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..290e750df20c6 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/dataset_stub_factory.cc @@ -29,6 +29,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultDatasetServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::DatasetService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..d491cb283ffa3 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/dataset_tracing_connection.cc @@ -385,6 +385,96 @@ 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)); +} + +StreamRange +DatasetServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::DatasetServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DatasetServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::DatasetServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status DatasetServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::DatasetServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status DatasetServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::DatasetServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +StatusOr +DatasetServiceTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::DatasetServiceConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(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..91827a87b5e80 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/dataset_tracing_connection.h @@ -178,6 +178,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..84a1aca6330ac 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/dataset_tracing_stub.cc @@ -376,6 +376,122 @@ 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)); +} + +StatusOr +DatasetServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.DatasetService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +DatasetServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.DatasetService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status DatasetServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.DatasetService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status DatasetServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.DatasetService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +StatusOr +DatasetServiceTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.DatasetService", "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(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..9d387745c42eb 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/dataset_tracing_stub.h @@ -185,6 +185,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..dd93af66a992c 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,94 @@ 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); +} + +StatusOr +DeploymentResourcePoolServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +DeploymentResourcePoolServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status DeploymentResourcePoolServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status DeploymentResourcePoolServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +StatusOr +DeploymentResourcePoolServiceAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(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..24ae4f899b2e5 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..16078714c347d 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,185 @@ 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__); +} + +StreamRange +DeploymentResourcePoolServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DeploymentResourcePoolServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DeploymentResourcePoolServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DeploymentResourcePoolServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +DeploymentResourcePoolServiceConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(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..644df1274b835 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,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..424a67da7717a 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,124 @@ 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_); +} + +StatusOr +DeploymentResourcePoolServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DeploymentResourcePoolServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DeploymentResourcePoolServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DeploymentResourcePoolServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DeploymentResourcePoolServiceLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(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..48a02beab4b4d 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..fd881f57d9a0b 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,96 @@ 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); +} + +StatusOr +DeploymentResourcePoolServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +DeploymentResourcePoolServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status DeploymentResourcePoolServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status DeploymentResourcePoolServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +StatusOr +DeploymentResourcePoolServiceMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(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..0e5f2ab320785 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..60238d084c5f5 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,125 @@ 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; +} + +StatusOr +DefaultDeploymentResourcePoolServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDeploymentResourcePoolServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultDeploymentResourcePoolServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultDeploymentResourcePoolServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultDeploymentResourcePoolServiceStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&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..823a8af8dc2f3 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,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -90,6 +92,48 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -110,9 +154,18 @@ class DefaultDeploymentResourcePoolServiceStub std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateDeploymentResourcePool( @@ -165,6 +218,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -181,6 +274,11 @@ class DefaultDeploymentResourcePoolServiceStub std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..2074b876c73f9 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,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -46,9 +49,15 @@ CreateDefaultDeploymentResourcePoolServiceStub( auto service_grpc_stub = google::cloud::aiplatform::v1::DeploymentResourcePoolService::NewStub( channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..4504c3d03ae98 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,101 @@ 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)); +} + +StreamRange +DeploymentResourcePoolServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::DeploymentResourcePoolServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DeploymentResourcePoolServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::DeploymentResourcePoolServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status DeploymentResourcePoolServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::DeploymentResourcePoolServiceConnection::" + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status DeploymentResourcePoolServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::DeploymentResourcePoolServiceConnection::" + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +StatusOr +DeploymentResourcePoolServiceTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::DeploymentResourcePoolServiceConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(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..64b1d492576a0 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,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..cd3c2c84ec81f 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,134 @@ 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)); +} + +StatusOr +DeploymentResourcePoolServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.DeploymentResourcePoolService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +DeploymentResourcePoolServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.DeploymentResourcePoolService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status DeploymentResourcePoolServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.DeploymentResourcePoolService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status DeploymentResourcePoolServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.DeploymentResourcePoolService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +StatusOr +DeploymentResourcePoolServiceTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.DeploymentResourcePoolService", + "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(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..a773b0b32ada7 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..cdd331b5fa6d3 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/endpoint_auth_decorator.cc @@ -199,6 +199,89 @@ 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); +} + +StatusOr +EndpointServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr EndpointServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status EndpointServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status EndpointServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +StatusOr EndpointServiceAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(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..910806f6c6834 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/endpoint_auth_decorator.h @@ -114,6 +114,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..49013876e9396 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/endpoint_connection_impl.cc @@ -594,6 +594,181 @@ 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__); +} + +StreamRange +EndpointServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +EndpointServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status EndpointServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status EndpointServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +EndpointServiceConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(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..6951c5081e48f 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/endpoint_connection_impl.h @@ -124,6 +124,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..9598ab1019837 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/endpoint_logging_decorator.cc @@ -227,6 +227,119 @@ 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_); +} + +StatusOr +EndpointServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr EndpointServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status EndpointServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status EndpointServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr EndpointServiceLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(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..c970333c433d3 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/endpoint_logging_decorator.h @@ -114,6 +114,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..4b84be446f5b1 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/endpoint_metadata_decorator.cc @@ -181,6 +181,92 @@ 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); +} + +StatusOr +EndpointServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr EndpointServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status EndpointServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status EndpointServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +StatusOr EndpointServiceMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(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..bc9e3fde4b2c0 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/endpoint_metadata_decorator.h @@ -115,6 +115,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..a29761d02b87c 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_stub.cc +++ b/google/cloud/aiplatform/v1/internal/endpoint_stub.cc @@ -220,6 +220,123 @@ 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; +} + +StatusOr +DefaultEndpointServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultEndpointServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultEndpointServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultEndpointServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultEndpointServiceStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&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..b82522cf6ef29 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_stub.h +++ b/google/cloud/aiplatform/v1/internal/endpoint_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -104,6 +106,48 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -123,9 +167,18 @@ class DefaultEndpointServiceStub : public EndpointServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::EndpointService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +255,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -217,6 +310,11 @@ class DefaultEndpointServiceStub : public EndpointServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..784ac6391a6fb 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/endpoint_stub_factory.cc @@ -29,6 +29,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultEndpointServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::EndpointService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..1405819d43190 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/endpoint_tracing_connection.cc @@ -207,6 +207,98 @@ 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)); +} + +StreamRange +EndpointServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::EndpointServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +EndpointServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::EndpointServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status EndpointServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::EndpointServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status EndpointServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::EndpointServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +StatusOr +EndpointServiceTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::EndpointServiceConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(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..032b5765a8b66 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/endpoint_tracing_connection.h @@ -112,6 +112,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..5a0b2a1e80bc2 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/endpoint_tracing_stub.cc @@ -201,6 +201,122 @@ 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)); +} + +StatusOr +EndpointServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.EndpointService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +EndpointServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.EndpointService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status EndpointServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.EndpointService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status EndpointServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.EndpointService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +StatusOr +EndpointServiceTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.EndpointService", "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(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..b67ea3d3b4b2c 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/endpoint_tracing_stub.h @@ -114,6 +114,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..9ce33b09c9967 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,94 @@ 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); +} + +StatusOr +FeatureOnlineStoreAdminServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +FeatureOnlineStoreAdminServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status FeatureOnlineStoreAdminServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status FeatureOnlineStoreAdminServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +StatusOr +FeatureOnlineStoreAdminServiceAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(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..9a02562f2a83d 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..a47b8d29bf2b2 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,185 @@ 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__); +} + +StreamRange +FeatureOnlineStoreAdminServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +FeatureOnlineStoreAdminServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status FeatureOnlineStoreAdminServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status FeatureOnlineStoreAdminServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +FeatureOnlineStoreAdminServiceConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(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..1bb71592f12e5 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,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..51810252dc1b6 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,124 @@ 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_); +} + +StatusOr +FeatureOnlineStoreAdminServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +FeatureOnlineStoreAdminServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status FeatureOnlineStoreAdminServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status FeatureOnlineStoreAdminServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +FeatureOnlineStoreAdminServiceLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(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..8bfc6a9aa8b08 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..04a2d630d3b9e 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,96 @@ 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); +} + +StatusOr +FeatureOnlineStoreAdminServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +FeatureOnlineStoreAdminServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status FeatureOnlineStoreAdminServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status FeatureOnlineStoreAdminServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +StatusOr +FeatureOnlineStoreAdminServiceMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(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..af7016f613c89 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..1f841f6abce12 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,125 @@ 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; +} + +StatusOr +DefaultFeatureOnlineStoreAdminServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultFeatureOnlineStoreAdminServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultFeatureOnlineStoreAdminServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultFeatureOnlineStoreAdminServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultFeatureOnlineStoreAdminServiceStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&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..b86e555944bcd 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,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -155,6 +157,48 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -175,9 +219,18 @@ class DefaultFeatureOnlineStoreAdminServiceStub std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateFeatureOnlineStore( @@ -292,6 +345,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -308,6 +401,11 @@ class DefaultFeatureOnlineStoreAdminServiceStub std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..cf7273aa76ee4 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,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -46,9 +49,15 @@ CreateDefaultFeatureOnlineStoreAdminServiceStub( auto service_grpc_stub = google::cloud::aiplatform::v1::FeatureOnlineStoreAdminService::NewStub( channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..f5e66fab917ba 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,102 @@ 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)); +} + +StreamRange +FeatureOnlineStoreAdminServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureOnlineStoreAdminServiceConnection::" + "ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +FeatureOnlineStoreAdminServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureOnlineStoreAdminServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status FeatureOnlineStoreAdminServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureOnlineStoreAdminServiceConnection::" + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status FeatureOnlineStoreAdminServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureOnlineStoreAdminServiceConnection::" + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +StatusOr +FeatureOnlineStoreAdminServiceTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureOnlineStoreAdminServiceConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(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..0cba9b13c61b5 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,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..24b92e9ff994c 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,134 @@ 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)); +} + +StatusOr +FeatureOnlineStoreAdminServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureOnlineStoreAdminService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +FeatureOnlineStoreAdminServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureOnlineStoreAdminService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status FeatureOnlineStoreAdminServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureOnlineStoreAdminService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status FeatureOnlineStoreAdminServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureOnlineStoreAdminService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +StatusOr +FeatureOnlineStoreAdminServiceTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureOnlineStoreAdminService", + "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(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..5d1dbe3bf7b09 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..0beabfeee82e9 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,92 @@ 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); +} + +StatusOr +FeatureOnlineStoreServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +FeatureOnlineStoreServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status FeatureOnlineStoreServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status FeatureOnlineStoreServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +StatusOr +FeatureOnlineStoreServiceAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(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..666982fce2a79 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..ffc4df20fe767 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,185 @@ 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__); +} + +StreamRange +FeatureOnlineStoreServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +FeatureOnlineStoreServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status FeatureOnlineStoreServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status FeatureOnlineStoreServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +FeatureOnlineStoreServiceConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(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..67b7640cc93a7 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,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..cb4178fb9c9e5 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,124 @@ 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_); +} + +StatusOr +FeatureOnlineStoreServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +FeatureOnlineStoreServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status FeatureOnlineStoreServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status FeatureOnlineStoreServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +FeatureOnlineStoreServiceLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(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..36499bd5187c2 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..fbc73edb970f7 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,96 @@ 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); +} + +StatusOr +FeatureOnlineStoreServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +FeatureOnlineStoreServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status FeatureOnlineStoreServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status FeatureOnlineStoreServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +StatusOr +FeatureOnlineStoreServiceMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(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..94bf0d6077a4e 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..37ff1f5a16bfd 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,125 @@ 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; +} + +StatusOr +DefaultFeatureOnlineStoreServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultFeatureOnlineStoreServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultFeatureOnlineStoreServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultFeatureOnlineStoreServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultFeatureOnlineStoreServiceStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&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..158b2bf263a23 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,9 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include #include #include @@ -46,6 +49,48 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; }; class DefaultFeatureOnlineStoreServiceStub @@ -54,8 +99,16 @@ class DefaultFeatureOnlineStoreServiceStub explicit DefaultFeatureOnlineStoreServiceStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr FetchFeatureValues( @@ -69,10 +122,55 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + private: std::unique_ptr< google::cloud::aiplatform::v1::FeatureOnlineStoreService::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..661fa97a4f9e3 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,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -46,9 +49,15 @@ CreateDefaultFeatureOnlineStoreServiceStub( auto service_grpc_stub = google::cloud::aiplatform::v1::FeatureOnlineStoreService::NewStub( channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..9142193544868 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,98 @@ 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)); +} + +StreamRange +FeatureOnlineStoreServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureOnlineStoreServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +FeatureOnlineStoreServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureOnlineStoreServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status FeatureOnlineStoreServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureOnlineStoreServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status FeatureOnlineStoreServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureOnlineStoreServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +StatusOr +FeatureOnlineStoreServiceTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureOnlineStoreServiceConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(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..3f965b9592ec0 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,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..16c93fe0a7ba2 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,127 @@ 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)); +} + +StatusOr +FeatureOnlineStoreServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureOnlineStoreService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +FeatureOnlineStoreServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureOnlineStoreService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status FeatureOnlineStoreServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureOnlineStoreService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status FeatureOnlineStoreServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureOnlineStoreService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +StatusOr +FeatureOnlineStoreServiceTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureOnlineStoreService", "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(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..1441ae0867ce0 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..f338d4f21fcac 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,92 @@ 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); +} + +StatusOr +FeatureRegistryServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +FeatureRegistryServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status FeatureRegistryServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status FeatureRegistryServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +StatusOr +FeatureRegistryServiceAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(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..4c330d3a79734 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..3937d511a052f 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,185 @@ 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__); +} + +StreamRange +FeatureRegistryServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +FeatureRegistryServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status FeatureRegistryServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status FeatureRegistryServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +FeatureRegistryServiceConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(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..001a12b7378f2 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,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..65c2d412a7bf9 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,122 @@ 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_); +} + +StatusOr +FeatureRegistryServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +FeatureRegistryServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status FeatureRegistryServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status FeatureRegistryServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +FeatureRegistryServiceLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(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..c554542f24116 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..66c11e8d4ec7d 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,94 @@ 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); +} + +StatusOr +FeatureRegistryServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +FeatureRegistryServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status FeatureRegistryServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status FeatureRegistryServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +StatusOr +FeatureRegistryServiceMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(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..259daf481c273 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..6d30f8af1b1f5 100644 --- a/google/cloud/aiplatform/v1/internal/feature_registry_stub.cc +++ b/google/cloud/aiplatform/v1/internal/feature_registry_stub.cc @@ -262,6 +262,125 @@ 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; +} + +StatusOr +DefaultFeatureRegistryServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultFeatureRegistryServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultFeatureRegistryServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultFeatureRegistryServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultFeatureRegistryServiceStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&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..89a083a4c713c 100644 --- a/google/cloud/aiplatform/v1/internal/feature_registry_stub.h +++ b/google/cloud/aiplatform/v1/internal/feature_registry_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -126,6 +128,48 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -145,9 +189,18 @@ class DefaultFeatureRegistryServiceStub : public FeatureRegistryServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::FeatureRegistryService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +294,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -257,6 +350,11 @@ class DefaultFeatureRegistryServiceStub : public FeatureRegistryServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::FeatureRegistryService::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..59c2b3e145b96 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,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -45,9 +48,15 @@ CreateDefaultFeatureRegistryServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::FeatureRegistryService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..a1d21b9ee19d7 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,98 @@ 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)); +} + +StreamRange +FeatureRegistryServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureRegistryServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +FeatureRegistryServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureRegistryServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status FeatureRegistryServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureRegistryServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status FeatureRegistryServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureRegistryServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +StatusOr +FeatureRegistryServiceTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureRegistryServiceConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(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..e276cf98c28b4 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,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..8069756183ffe 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,125 @@ 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)); +} + +StatusOr +FeatureRegistryServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureRegistryService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +FeatureRegistryServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureRegistryService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status FeatureRegistryServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureRegistryService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status FeatureRegistryServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureRegistryService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +StatusOr +FeatureRegistryServiceTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureRegistryService", "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(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..174b8b87f8d9b 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..3c6e519991a32 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/featurestore_auth_decorator.cc @@ -460,6 +460,90 @@ 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); +} + +StatusOr +FeaturestoreServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr FeaturestoreServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status FeaturestoreServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status FeaturestoreServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +StatusOr FeaturestoreServiceAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(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..e0968a62866b1 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/featurestore_auth_decorator.h @@ -228,6 +228,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..29e7cfd5f9a8e 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/featurestore_connection_impl.cc @@ -1406,6 +1406,183 @@ 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__); +} + +StreamRange +FeaturestoreServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +FeaturestoreServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status FeaturestoreServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status FeaturestoreServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +FeaturestoreServiceConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(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..5daf4b771d1bb 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/featurestore_connection_impl.h @@ -238,6 +238,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..1cffac611d310 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/featurestore_logging_decorator.cc @@ -537,6 +537,122 @@ 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_); +} + +StatusOr +FeaturestoreServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +FeaturestoreServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status FeaturestoreServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status FeaturestoreServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +FeaturestoreServiceLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(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..ae22c91068a23 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/featurestore_logging_decorator.h @@ -228,6 +228,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..9106fdfc69bfb 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/featurestore_metadata_decorator.cc @@ -392,6 +392,94 @@ 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); +} + +StatusOr +FeaturestoreServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +FeaturestoreServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status FeaturestoreServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status FeaturestoreServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +StatusOr +FeaturestoreServiceMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(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..aff8a544ccdd0 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/featurestore_metadata_decorator.h @@ -229,6 +229,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..9030868cf78c2 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,94 @@ 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); +} + +StatusOr +FeaturestoreOnlineServingServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +FeaturestoreOnlineServingServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status FeaturestoreOnlineServingServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status FeaturestoreOnlineServingServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +StatusOr +FeaturestoreOnlineServingServiceAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(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..cd1a3e72d1d40 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..36938fbc765ba 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,185 @@ 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__); +} + +StreamRange +FeaturestoreOnlineServingServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +FeaturestoreOnlineServingServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status FeaturestoreOnlineServingServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status FeaturestoreOnlineServingServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +FeaturestoreOnlineServingServiceConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(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..991a1f0c7f3dd 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,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..8c7daae5589de 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,124 @@ 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_); +} + +StatusOr +FeaturestoreOnlineServingServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +FeaturestoreOnlineServingServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status FeaturestoreOnlineServingServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status FeaturestoreOnlineServingServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +FeaturestoreOnlineServingServiceLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(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..934acbee744cb 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..9b9d312bfeda1 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,96 @@ 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); +} + +StatusOr +FeaturestoreOnlineServingServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +FeaturestoreOnlineServingServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status FeaturestoreOnlineServingServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status FeaturestoreOnlineServingServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +StatusOr +FeaturestoreOnlineServingServiceMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(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..f737e1ba1ee1d 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..6a584b1cbf124 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,125 @@ 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; +} + +StatusOr +DefaultFeaturestoreOnlineServingServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultFeaturestoreOnlineServingServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultFeaturestoreOnlineServingServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultFeaturestoreOnlineServingServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultFeaturestoreOnlineServingServiceStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&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..08f42e67e90ff 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,9 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include #include #include @@ -54,6 +57,48 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; }; class DefaultFeaturestoreOnlineServingServiceStub @@ -62,8 +107,16 @@ class DefaultFeaturestoreOnlineServingServiceStub explicit DefaultFeaturestoreOnlineServingServiceStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ReadFeatureValues( @@ -84,10 +137,55 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..4dd7bde13e473 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,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -46,9 +49,15 @@ CreateDefaultFeaturestoreOnlineServingServiceStub( auto service_grpc_stub = google::cloud::aiplatform::v1::FeaturestoreOnlineServingService::NewStub( channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..ba7ffd0928bc5 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,107 @@ 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)); +} + +StreamRange +FeaturestoreOnlineServingServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeaturestoreOnlineServingServiceConnection::" + "ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +FeaturestoreOnlineServingServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeaturestoreOnlineServingServiceConnection::" + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status FeaturestoreOnlineServingServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeaturestoreOnlineServingServiceConnection::" + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status FeaturestoreOnlineServingServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeaturestoreOnlineServingServiceConnection::" + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +StatusOr +FeaturestoreOnlineServingServiceTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeaturestoreOnlineServingServiceConnection::" + "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(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..418a08aafa2e0 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,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..da2abd7e3dc0d 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,134 @@ 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)); +} + +StatusOr +FeaturestoreOnlineServingServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeaturestoreOnlineServingService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +FeaturestoreOnlineServingServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeaturestoreOnlineServingService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status FeaturestoreOnlineServingServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeaturestoreOnlineServingService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status FeaturestoreOnlineServingServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeaturestoreOnlineServingService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +StatusOr +FeaturestoreOnlineServingServiceTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeaturestoreOnlineServingService", + "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(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..5cc9249bc780a 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..b350776136a97 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_stub.cc +++ b/google/cloud/aiplatform/v1/internal/featurestore_stub.cc @@ -512,6 +512,123 @@ 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; +} + +StatusOr +DefaultFeaturestoreServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultFeaturestoreServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultFeaturestoreServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultFeaturestoreServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultFeaturestoreServiceStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&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..59af87bd693fb 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_stub.h +++ b/google/cloud/aiplatform/v1/internal/featurestore_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -230,6 +232,48 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -249,9 +293,18 @@ class DefaultFeaturestoreServiceStub : public FeaturestoreServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::FeaturestoreService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +495,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -458,6 +551,11 @@ class DefaultFeaturestoreServiceStub : public FeaturestoreServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::FeaturestoreService::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..a883f3b036aa7 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/featurestore_stub_factory.cc @@ -29,6 +29,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultFeaturestoreServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::FeaturestoreService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..a616ea9ebeea3 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/featurestore_tracing_connection.cc @@ -490,6 +490,98 @@ 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)); +} + +StreamRange +FeaturestoreServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeaturestoreServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +FeaturestoreServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeaturestoreServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status FeaturestoreServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeaturestoreServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status FeaturestoreServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeaturestoreServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +StatusOr +FeaturestoreServiceTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeaturestoreServiceConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(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..15853b5c74622 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/featurestore_tracing_connection.h @@ -226,6 +226,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..3083bcc9771cc 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/featurestore_tracing_stub.cc @@ -467,6 +467,122 @@ 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)); +} + +StatusOr +FeaturestoreServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeaturestoreService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +FeaturestoreServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeaturestoreService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status FeaturestoreServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeaturestoreService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status FeaturestoreServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeaturestoreService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +StatusOr +FeaturestoreServiceTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeaturestoreService", "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(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..a57448bbc80da 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/featurestore_tracing_stub.h @@ -228,6 +228,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..9fe727211a922 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,89 @@ 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); +} + +StatusOr +GenAiTuningServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr GenAiTuningServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status GenAiTuningServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status GenAiTuningServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +StatusOr GenAiTuningServiceAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(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..52e874603864e 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..46f9bfb0a1322 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,183 @@ 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__); +} + +StreamRange +GenAiTuningServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +GenAiTuningServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status GenAiTuningServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status GenAiTuningServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +GenAiTuningServiceConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(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..c48193e4e1f85 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,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..edd76d2275e95 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,122 @@ 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_); +} + +StatusOr +GenAiTuningServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +GenAiTuningServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status GenAiTuningServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status GenAiTuningServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +GenAiTuningServiceLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(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..ea2c1224a47c9 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..e8567c23c5725 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,94 @@ 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); +} + +StatusOr +GenAiTuningServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +GenAiTuningServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status GenAiTuningServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status GenAiTuningServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +StatusOr +GenAiTuningServiceMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(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..e3d9309eb8c79 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..ceb0414f162e2 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,123 @@ 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; +} + +StatusOr +DefaultGenAiTuningServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultGenAiTuningServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultGenAiTuningServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultGenAiTuningServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultGenAiTuningServiceStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&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..b9f34760abc3a 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,9 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include #include #include @@ -51,6 +54,48 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; }; class DefaultGenAiTuningServiceStub : public GenAiTuningServiceStub { @@ -58,8 +103,16 @@ 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 + operations_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr CreateTuningJob( grpc::ClientContext& context, Options const& options, @@ -81,10 +134,55 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + private: std::unique_ptr< google::cloud::aiplatform::v1::GenAiTuningService::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..b2b00c2fe0869 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,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultGenAiTuningServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::GenAiTuningService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..6cddb7260c40b 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,98 @@ 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)); +} + +StreamRange +GenAiTuningServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::GenAiTuningServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +GenAiTuningServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::GenAiTuningServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status GenAiTuningServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::GenAiTuningServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status GenAiTuningServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::GenAiTuningServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +StatusOr +GenAiTuningServiceTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::GenAiTuningServiceConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(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..67f90db313a13 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,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..08f95a7ff56a8 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,122 @@ 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)); +} + +StatusOr +GenAiTuningServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.GenAiTuningService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +GenAiTuningServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.GenAiTuningService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status GenAiTuningServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.GenAiTuningService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status GenAiTuningServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.GenAiTuningService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +StatusOr +GenAiTuningServiceTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.GenAiTuningService", "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(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..89bf33295b8a9 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..6f7bf9cdb718e 100644 --- a/google/cloud/aiplatform/v1/internal/index_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/index_auth_decorator.cc @@ -150,6 +150,89 @@ 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); +} + +StatusOr +IndexServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr IndexServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status IndexServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status IndexServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +StatusOr IndexServiceAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(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..7d615341d6e85 100644 --- a/google/cloud/aiplatform/v1/internal/index_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/index_auth_decorator.h @@ -94,6 +94,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..e6a9322fa0a04 100644 --- a/google/cloud/aiplatform/v1/internal/index_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/index_connection_impl.cc @@ -416,6 +416,181 @@ 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__); +} + +StreamRange +IndexServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +IndexServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status IndexServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status IndexServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +IndexServiceConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(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..88f90b7a8bca9 100644 --- a/google/cloud/aiplatform/v1/internal/index_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/index_connection_impl.h @@ -102,6 +102,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..388da09f4b777 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,91 @@ 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); +} + +StatusOr +IndexEndpointServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr IndexEndpointServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status IndexEndpointServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status IndexEndpointServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +StatusOr +IndexEndpointServiceAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(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..9df9faadf5387 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..b321cbba6e7cb 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,183 @@ 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__); +} + +StreamRange +IndexEndpointServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +IndexEndpointServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status IndexEndpointServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status IndexEndpointServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +IndexEndpointServiceConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(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..a9455057c8d48 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,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..83e0630fc4c59 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,122 @@ 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_); +} + +StatusOr +IndexEndpointServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +IndexEndpointServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status IndexEndpointServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status IndexEndpointServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +IndexEndpointServiceLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(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..807dd358d4e29 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..565e93006d0c7 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,94 @@ 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); +} + +StatusOr +IndexEndpointServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +IndexEndpointServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status IndexEndpointServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status IndexEndpointServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +StatusOr +IndexEndpointServiceMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(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..43b5f368e9119 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..53cd64e976da5 100644 --- a/google/cloud/aiplatform/v1/internal/index_endpoint_stub.cc +++ b/google/cloud/aiplatform/v1/internal/index_endpoint_stub.cc @@ -220,6 +220,123 @@ 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; +} + +StatusOr +DefaultIndexEndpointServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultIndexEndpointServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultIndexEndpointServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultIndexEndpointServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultIndexEndpointServiceStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&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..6883a653cc176 100644 --- a/google/cloud/aiplatform/v1/internal/index_endpoint_stub.h +++ b/google/cloud/aiplatform/v1/internal/index_endpoint_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -114,6 +116,48 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -133,9 +177,18 @@ class DefaultIndexEndpointServiceStub : public IndexEndpointServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::IndexEndpointService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +266,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -229,6 +322,11 @@ class DefaultIndexEndpointServiceStub : public IndexEndpointServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::IndexEndpointService::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..9c1f17ed64bed 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,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultIndexEndpointServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::IndexEndpointService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..eda5cfea4d0a9 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,98 @@ 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)); +} + +StreamRange +IndexEndpointServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::IndexEndpointServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +IndexEndpointServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::IndexEndpointServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status IndexEndpointServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::IndexEndpointServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status IndexEndpointServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::IndexEndpointServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +StatusOr +IndexEndpointServiceTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::IndexEndpointServiceConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(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..6e52b5bebbc76 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,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..0c6ebc04e7ed2 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,122 @@ 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)); +} + +StatusOr +IndexEndpointServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.IndexEndpointService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +IndexEndpointServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.IndexEndpointService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status IndexEndpointServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.IndexEndpointService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status IndexEndpointServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.IndexEndpointService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +StatusOr +IndexEndpointServiceTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.IndexEndpointService", "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(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..3253974c179c7 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..a0317bf9a67ea 100644 --- a/google/cloud/aiplatform/v1/internal/index_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/index_logging_decorator.cc @@ -171,6 +171,119 @@ 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_); +} + +StatusOr +IndexServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr IndexServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status IndexServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status IndexServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr IndexServiceLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(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..ff27751de1f6a 100644 --- a/google/cloud/aiplatform/v1/internal/index_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/index_logging_decorator.h @@ -94,6 +94,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..512b560c07978 100644 --- a/google/cloud/aiplatform/v1/internal/index_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/index_metadata_decorator.cc @@ -141,6 +141,91 @@ 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); +} + +StatusOr +IndexServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr IndexServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status IndexServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status IndexServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +StatusOr IndexServiceMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(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..60b3115519c75 100644 --- a/google/cloud/aiplatform/v1/internal/index_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/index_metadata_decorator.h @@ -94,6 +94,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..1ab41e1a6c499 100644 --- a/google/cloud/aiplatform/v1/internal/index_stub.cc +++ b/google/cloud/aiplatform/v1/internal/index_stub.cc @@ -166,6 +166,121 @@ 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; +} + +StatusOr +DefaultIndexServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultIndexServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultIndexServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultIndexServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr DefaultIndexServiceStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&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..a62ca3864d3a5 100644 --- a/google/cloud/aiplatform/v1/internal/index_stub.h +++ b/google/cloud/aiplatform/v1/internal/index_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -87,6 +89,48 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -106,9 +150,18 @@ class DefaultIndexServiceStub : public IndexServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::IndexService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +218,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -180,6 +273,11 @@ class DefaultIndexServiceStub : public IndexServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..498df850dc0be 100644 --- a/google/cloud/aiplatform/v1/internal/index_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/index_stub_factory.cc @@ -29,6 +29,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultIndexServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::IndexService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..63e47c99bcd79 100644 --- a/google/cloud/aiplatform/v1/internal/index_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/index_tracing_connection.cc @@ -155,6 +155,96 @@ 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)); +} + +StreamRange +IndexServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::IndexServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +IndexServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("aiplatform_v1::IndexServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status IndexServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::IndexServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status IndexServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::IndexServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +StatusOr +IndexServiceTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::IndexServiceConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(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..b8762c0754e54 100644 --- a/google/cloud/aiplatform/v1/internal/index_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/index_tracing_connection.h @@ -90,6 +90,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..d97b44f113337 100644 --- a/google/cloud/aiplatform/v1/internal/index_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/index_tracing_stub.cc @@ -155,6 +155,120 @@ 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)); +} + +StatusOr +IndexServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.IndexService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr IndexServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.IndexService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status IndexServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.IndexService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status IndexServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.IndexService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +StatusOr IndexServiceTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.IndexService", + "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(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..f56724dd48c5b 100644 --- a/google/cloud/aiplatform/v1/internal/index_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/index_tracing_stub.h @@ -93,6 +93,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..6618f31d44575 100644 --- a/google/cloud/aiplatform/v1/internal/job_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/job_auth_decorator.cc @@ -502,6 +502,89 @@ 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); +} + +StatusOr +JobServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr JobServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status JobServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status JobServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +StatusOr JobServiceAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(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..b9b9db5971119 100644 --- a/google/cloud/aiplatform/v1/internal/job_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/job_auth_decorator.h @@ -281,6 +281,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..34aee1482abcd 100644 --- a/google/cloud/aiplatform/v1/internal/job_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/job_connection_impl.cc @@ -1340,6 +1340,180 @@ 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__); +} + +StreamRange +JobServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr JobServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status JobServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status JobServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +JobServiceConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(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..4a1e9093b9a7b 100644 --- a/google/cloud/aiplatform/v1/internal/job_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/job_connection_impl.h @@ -266,6 +266,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..7246f93d8cded 100644 --- a/google/cloud/aiplatform/v1/internal/job_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/job_logging_decorator.cc @@ -652,6 +652,119 @@ 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_); +} + +StatusOr +JobServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr JobServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status JobServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status JobServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr JobServiceLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(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..ceb3aaa9986e8 100644 --- a/google/cloud/aiplatform/v1/internal/job_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/job_logging_decorator.h @@ -281,6 +281,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..bbbb689befcde 100644 --- a/google/cloud/aiplatform/v1/internal/job_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/job_metadata_decorator.cc @@ -470,6 +470,91 @@ 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); +} + +StatusOr +JobServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr JobServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status JobServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status JobServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +StatusOr JobServiceMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(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..9cecf5e666b98 100644 --- a/google/cloud/aiplatform/v1/internal/job_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/job_metadata_decorator.h @@ -281,6 +281,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..ddc4f51c626af 100644 --- a/google/cloud/aiplatform/v1/internal/job_stub.cc +++ b/google/cloud/aiplatform/v1/internal/job_stub.cc @@ -625,6 +625,120 @@ 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; +} + +StatusOr +DefaultJobServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultJobServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultJobServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultJobServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr DefaultJobServiceStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&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..4c2521e05c2d6 100644 --- a/google/cloud/aiplatform/v1/internal/job_stub.h +++ b/google/cloud/aiplatform/v1/internal/job_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -280,6 +282,48 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -298,9 +342,18 @@ class DefaultJobServiceStub : public JobServiceStub { DefaultJobServiceStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +597,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -559,6 +652,11 @@ class DefaultJobServiceStub : public JobServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..bdf4a368406f0 100644 --- a/google/cloud/aiplatform/v1/internal/job_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/job_stub_factory.cc @@ -29,6 +29,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultJobServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::JobService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..653d4fe2aab00 100644 --- a/google/cloud/aiplatform/v1/internal/job_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/job_tracing_connection.cc @@ -551,6 +551,96 @@ 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)); +} + +StreamRange +JobServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("aiplatform_v1::JobServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +JobServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("aiplatform_v1::JobServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status JobServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::JobServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status JobServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::JobServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +StatusOr +JobServiceTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = + internal::MakeSpan("aiplatform_v1::JobServiceConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(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..04da12fc38384 100644 --- a/google/cloud/aiplatform/v1/internal/job_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/job_tracing_connection.h @@ -254,6 +254,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..0898fa7512a9a 100644 --- a/google/cloud/aiplatform/v1/internal/job_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/job_tracing_stub.cc @@ -594,6 +594,119 @@ 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)); +} + +StatusOr +JobServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.JobService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr JobServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.JobService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status JobServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.JobService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status JobServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.JobService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +StatusOr JobServiceTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.JobService", + "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(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..fb656016fe6ad 100644 --- a/google/cloud/aiplatform/v1/internal/job_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/job_tracing_stub.h @@ -280,6 +280,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..0b3f3b0b3d80a 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,89 @@ 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); +} + +StatusOr +LlmUtilityServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr LlmUtilityServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status LlmUtilityServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status LlmUtilityServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +StatusOr LlmUtilityServiceAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(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..313b1633c078c 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..93b9266ec57fc 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,181 @@ 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__); +} + +StreamRange +LlmUtilityServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +LlmUtilityServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status LlmUtilityServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status LlmUtilityServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +LlmUtilityServiceConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(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..f0659ef9b2ea0 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,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..70061887b3012 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,121 @@ 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_); +} + +StatusOr +LlmUtilityServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr LlmUtilityServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status LlmUtilityServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status LlmUtilityServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +LlmUtilityServiceLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(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..67e869dd373e6 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..717f722c77191 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,94 @@ 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); +} + +StatusOr +LlmUtilityServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +LlmUtilityServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status LlmUtilityServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status LlmUtilityServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +StatusOr +LlmUtilityServiceMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(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..d423f5a540ead 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..8ee839c47f102 100644 --- a/google/cloud/aiplatform/v1/internal/llm_utility_stub.cc +++ b/google/cloud/aiplatform/v1/internal/llm_utility_stub.cc @@ -54,6 +54,123 @@ 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; +} + +StatusOr +DefaultLlmUtilityServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultLlmUtilityServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultLlmUtilityServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultLlmUtilityServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultLlmUtilityServiceStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&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..01e3c91d90f77 100644 --- a/google/cloud/aiplatform/v1/internal/llm_utility_stub.h +++ b/google/cloud/aiplatform/v1/internal/llm_utility_stub.h @@ -23,6 +23,9 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include #include #include @@ -44,6 +47,48 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; }; class DefaultLlmUtilityServiceStub : public LlmUtilityServiceStub { @@ -51,8 +96,16 @@ 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 + operations_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr CountTokens( grpc::ClientContext& context, Options const& options, @@ -64,10 +117,55 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + private: std::unique_ptr< google::cloud::aiplatform::v1::LlmUtilityService::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..c842326478816 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,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultLlmUtilityServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::LlmUtilityService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..c87ebad3c7479 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,98 @@ 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)); +} + +StreamRange +LlmUtilityServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::LlmUtilityServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +LlmUtilityServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::LlmUtilityServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status LlmUtilityServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::LlmUtilityServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status LlmUtilityServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::LlmUtilityServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +StatusOr +LlmUtilityServiceTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::LlmUtilityServiceConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(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..ce19704faf7f0 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,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..d6b3f67afd1eb 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,122 @@ 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)); +} + +StatusOr +LlmUtilityServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.LlmUtilityService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +LlmUtilityServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.LlmUtilityService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status LlmUtilityServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.LlmUtilityService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status LlmUtilityServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.LlmUtilityService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +StatusOr +LlmUtilityServiceTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.LlmUtilityService", "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(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..73d3c59dc56e5 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..169a2aad33276 100644 --- a/google/cloud/aiplatform/v1/internal/match_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/match_auth_decorator.cc @@ -49,6 +49,89 @@ 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); +} + +StatusOr +MatchServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr MatchServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status MatchServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status MatchServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +StatusOr MatchServiceAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(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..2251b55d9da20 100644 --- a/google/cloud/aiplatform/v1/internal/match_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/match_auth_decorator.h @@ -49,6 +49,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..0a62a4b1315b4 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,181 @@ 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__); +} + +StreamRange +MatchServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +MatchServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status MatchServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status MatchServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +MatchServiceConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(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..347390803bc0a 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,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..07b6461e09bb8 100644 --- a/google/cloud/aiplatform/v1/internal/match_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/match_logging_decorator.cc @@ -61,6 +61,119 @@ 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_); +} + +StatusOr +MatchServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr MatchServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status MatchServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status MatchServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr MatchServiceLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(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..b1b503c7139b6 100644 --- a/google/cloud/aiplatform/v1/internal/match_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/match_logging_decorator.h @@ -49,6 +49,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..3a9b866f30ad6 100644 --- a/google/cloud/aiplatform/v1/internal/match_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/match_metadata_decorator.cc @@ -64,6 +64,91 @@ 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); +} + +StatusOr +MatchServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr MatchServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status MatchServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status MatchServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +StatusOr MatchServiceMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(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..ab3c176f80985 100644 --- a/google/cloud/aiplatform/v1/internal/match_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/match_metadata_decorator.h @@ -49,6 +49,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..01c5625626eb5 100644 --- a/google/cloud/aiplatform/v1/internal/match_stub.cc +++ b/google/cloud/aiplatform/v1/internal/match_stub.cc @@ -54,6 +54,121 @@ 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; +} + +StatusOr +DefaultMatchServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultMatchServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultMatchServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultMatchServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr DefaultMatchServiceStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&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..1f873ad330e02 100644 --- a/google/cloud/aiplatform/v1/internal/match_stub.h +++ b/google/cloud/aiplatform/v1/internal/match_stub.h @@ -23,6 +23,9 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include #include #include @@ -45,6 +48,48 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; }; class DefaultMatchServiceStub : public MatchServiceStub { @@ -52,8 +97,16 @@ 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 + operations_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr FindNeighbors( grpc::ClientContext& context, Options const& options, @@ -66,9 +119,54 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..ddc23fb9581ed 100644 --- a/google/cloud/aiplatform/v1/internal/match_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/match_stub_factory.cc @@ -29,6 +29,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,8 +47,15 @@ std::shared_ptr CreateDefaultMatchServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::MatchService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..11f580130ac5a 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,96 @@ 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)); +} + +StreamRange +MatchServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::MatchServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +MatchServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("aiplatform_v1::MatchServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status MatchServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::MatchServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status MatchServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::MatchServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +StatusOr +MatchServiceTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::MatchServiceConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(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..9fde896895324 100644 --- a/google/cloud/aiplatform/v1/internal/match_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/match_tracing_connection.h @@ -49,6 +49,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..ac69ace20446d 100644 --- a/google/cloud/aiplatform/v1/internal/match_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/match_tracing_stub.cc @@ -56,6 +56,120 @@ 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)); +} + +StatusOr +MatchServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.MatchService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr MatchServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.MatchService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status MatchServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.MatchService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status MatchServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.MatchService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +StatusOr MatchServiceTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.MatchService", + "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(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..af9f24428d6dc 100644 --- a/google/cloud/aiplatform/v1/internal/match_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/match_tracing_stub.h @@ -49,6 +49,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..bca5649794111 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/metadata_auth_decorator.cc @@ -479,6 +479,89 @@ 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); +} + +StatusOr +MetadataServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr MetadataServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status MetadataServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status MetadataServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +StatusOr MetadataServiceAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(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..75ffb3cbcc251 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/metadata_auth_decorator.h @@ -264,6 +264,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..d0a81bf08b91b 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/metadata_connection_impl.cc @@ -1279,6 +1279,181 @@ 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__); +} + +StreamRange +MetadataServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +MetadataServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status MetadataServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status MetadataServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +MetadataServiceConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(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..0584c00d57a1d 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/metadata_connection_impl.h @@ -252,6 +252,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..8f8c1954c23b9 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/metadata_logging_decorator.cc @@ -605,6 +605,119 @@ 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_); +} + +StatusOr +MetadataServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr MetadataServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status MetadataServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status MetadataServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr MetadataServiceLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(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..d362e4b8e434b 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/metadata_logging_decorator.h @@ -264,6 +264,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..d682e4451e579 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/metadata_metadata_decorator.cc @@ -438,6 +438,92 @@ 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); +} + +StatusOr +MetadataServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr MetadataServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status MetadataServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status MetadataServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +StatusOr MetadataServiceMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(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..bed00b283513d 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/metadata_metadata_decorator.h @@ -265,6 +265,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..b88b94bc82a23 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_stub.cc +++ b/google/cloud/aiplatform/v1/internal/metadata_stub.cc @@ -576,6 +576,123 @@ 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; +} + +StatusOr +DefaultMetadataServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultMetadataServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultMetadataServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultMetadataServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultMetadataServiceStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&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..615d4b92bf282 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_stub.h +++ b/google/cloud/aiplatform/v1/internal/metadata_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -247,6 +249,48 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -266,9 +310,18 @@ class DefaultMetadataServiceStub : public MetadataServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::MetadataService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +548,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -510,6 +603,11 @@ class DefaultMetadataServiceStub : public MetadataServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..f5268a4715529 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/metadata_stub_factory.cc @@ -29,6 +29,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultMetadataServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::MetadataService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..2633507caf6a5 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/metadata_tracing_connection.cc @@ -508,6 +508,98 @@ 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)); +} + +StreamRange +MetadataServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::MetadataServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +MetadataServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::MetadataServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status MetadataServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::MetadataServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status MetadataServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::MetadataServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +StatusOr +MetadataServiceTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::MetadataServiceConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(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..f0958482808da 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/metadata_tracing_connection.h @@ -240,6 +240,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..267484029bc4d 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/metadata_tracing_stub.cc @@ -548,6 +548,122 @@ 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)); +} + +StatusOr +MetadataServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.MetadataService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +MetadataServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.MetadataService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status MetadataServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.MetadataService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status MetadataServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.MetadataService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +StatusOr +MetadataServiceTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.MetadataService", "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(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..f5612096e0300 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/metadata_tracing_stub.h @@ -264,6 +264,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..b979a135d774f 100644 --- a/google/cloud/aiplatform/v1/internal/migration_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/migration_auth_decorator.cc @@ -72,6 +72,89 @@ 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); +} + +StatusOr +MigrationServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr MigrationServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status MigrationServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status MigrationServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +StatusOr MigrationServiceAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(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..9cd7bfc76b989 100644 --- a/google/cloud/aiplatform/v1/internal/migration_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/migration_auth_decorator.h @@ -57,6 +57,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..e42b4f94f5e74 100644 --- a/google/cloud/aiplatform/v1/internal/migration_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/migration_connection_impl.cc @@ -199,6 +199,181 @@ 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__); +} + +StreamRange +MigrationServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +MigrationServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status MigrationServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status MigrationServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +MigrationServiceConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(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..945462fa06fad 100644 --- a/google/cloud/aiplatform/v1/internal/migration_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/migration_connection_impl.h @@ -71,6 +71,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..c79c84beda3b1 100644 --- a/google/cloud/aiplatform/v1/internal/migration_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/migration_logging_decorator.cc @@ -84,6 +84,120 @@ 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_); +} + +StatusOr +MigrationServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr MigrationServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status MigrationServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status MigrationServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr MigrationServiceLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(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..a1b5aa18c5635 100644 --- a/google/cloud/aiplatform/v1/internal/migration_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/migration_logging_decorator.h @@ -57,6 +57,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..fd58fa7db4557 100644 --- a/google/cloud/aiplatform/v1/internal/migration_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/migration_metadata_decorator.cc @@ -77,6 +77,93 @@ 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); +} + +StatusOr +MigrationServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr MigrationServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status MigrationServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status MigrationServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +StatusOr +MigrationServiceMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(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..b6d1549b80f31 100644 --- a/google/cloud/aiplatform/v1/internal/migration_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/migration_metadata_decorator.h @@ -58,6 +58,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..0cd48600786b7 100644 --- a/google/cloud/aiplatform/v1/internal/migration_stub.cc +++ b/google/cloud/aiplatform/v1/internal/migration_stub.cc @@ -78,6 +78,123 @@ 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; +} + +StatusOr +DefaultMigrationServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultMigrationServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultMigrationServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultMigrationServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultMigrationServiceStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&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..d037aee11a56a 100644 --- a/google/cloud/aiplatform/v1/internal/migration_stub.h +++ b/google/cloud/aiplatform/v1/internal/migration_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -58,6 +60,48 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -77,9 +121,18 @@ class DefaultMigrationServiceStub : public MigrationServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::MigrationService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr SearchMigratableResources( @@ -99,6 +152,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -115,6 +208,11 @@ class DefaultMigrationServiceStub : public MigrationServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::MigrationService::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..7df47c24c243d 100644 --- a/google/cloud/aiplatform/v1/internal/migration_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/migration_stub_factory.cc @@ -29,6 +29,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultMigrationServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::MigrationService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..21aa88a6a5a81 100644 --- a/google/cloud/aiplatform/v1/internal/migration_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/migration_tracing_connection.cc @@ -78,6 +78,98 @@ 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)); +} + +StreamRange +MigrationServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::MigrationServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +MigrationServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::MigrationServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status MigrationServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::MigrationServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status MigrationServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::MigrationServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +StatusOr +MigrationServiceTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::MigrationServiceConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(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..68b4edd35e6c4 100644 --- a/google/cloud/aiplatform/v1/internal/migration_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/migration_tracing_connection.h @@ -59,6 +59,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..27f46567ec427 100644 --- a/google/cloud/aiplatform/v1/internal/migration_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/migration_tracing_stub.cc @@ -76,6 +76,122 @@ 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)); +} + +StatusOr +MigrationServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.MigrationService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +MigrationServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.MigrationService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status MigrationServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.MigrationService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status MigrationServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.MigrationService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +StatusOr +MigrationServiceTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.MigrationService", "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(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..340b34282df10 100644 --- a/google/cloud/aiplatform/v1/internal/migration_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/migration_tracing_stub.h @@ -57,6 +57,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..047dab7c74950 100644 --- a/google/cloud/aiplatform/v1/internal/model_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/model_auth_decorator.cc @@ -314,6 +314,89 @@ 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); +} + +StatusOr +ModelServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr ModelServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status ModelServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status ModelServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +StatusOr ModelServiceAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(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..7e557455a9579 100644 --- a/google/cloud/aiplatform/v1/internal/model_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/model_auth_decorator.h @@ -177,6 +177,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..d4d94987e8e68 100644 --- a/google/cloud/aiplatform/v1/internal/model_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/model_connection_impl.cc @@ -889,6 +889,181 @@ 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__); +} + +StreamRange +ModelServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ModelServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ModelServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ModelServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +ModelServiceConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(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..ab078291d0aa3 100644 --- a/google/cloud/aiplatform/v1/internal/model_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/model_connection_impl.h @@ -180,6 +180,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..585c065e311b4 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,89 @@ 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); +} + +StatusOr +ModelGardenServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr ModelGardenServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status ModelGardenServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status ModelGardenServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +StatusOr ModelGardenServiceAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(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..adbe7d2a5fab0 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..0173799385b7f 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,183 @@ 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__); +} + +StreamRange +ModelGardenServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ModelGardenServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ModelGardenServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ModelGardenServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +ModelGardenServiceConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(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..9fb87570607e4 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,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..d3e8b929794c1 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,122 @@ 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_); +} + +StatusOr +ModelGardenServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ModelGardenServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ModelGardenServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ModelGardenServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ModelGardenServiceLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(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..acb905313d9ea 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..9014d3b694388 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,94 @@ 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); +} + +StatusOr +ModelGardenServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +ModelGardenServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status ModelGardenServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status ModelGardenServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +StatusOr +ModelGardenServiceMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(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..1959f23283c53 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..488983d2f4e3f 100644 --- a/google/cloud/aiplatform/v1/internal/model_garden_stub.cc +++ b/google/cloud/aiplatform/v1/internal/model_garden_stub.cc @@ -42,6 +42,123 @@ 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; +} + +StatusOr +DefaultModelGardenServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultModelGardenServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultModelGardenServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultModelGardenServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultModelGardenServiceStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&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..166d55cddebec 100644 --- a/google/cloud/aiplatform/v1/internal/model_garden_stub.h +++ b/google/cloud/aiplatform/v1/internal/model_garden_stub.h @@ -23,6 +23,9 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include #include #include @@ -40,6 +43,48 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; }; class DefaultModelGardenServiceStub : public ModelGardenServiceStub { @@ -47,18 +92,71 @@ 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 + operations_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + private: std::unique_ptr< google::cloud::aiplatform::v1::ModelGardenService::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..6d4fa22454e50 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,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultModelGardenServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::ModelGardenService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..dfc789cb800fa 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,98 @@ 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)); +} + +StreamRange +ModelGardenServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::ModelGardenServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ModelGardenServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::ModelGardenServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status ModelGardenServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::ModelGardenServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status ModelGardenServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::ModelGardenServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +StatusOr +ModelGardenServiceTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::ModelGardenServiceConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(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..d3c85fa888440 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,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..05aee4bdc3be5 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,122 @@ 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)); +} + +StatusOr +ModelGardenServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.ModelGardenService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +ModelGardenServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.ModelGardenService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status ModelGardenServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.ModelGardenService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status ModelGardenServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.ModelGardenService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +StatusOr +ModelGardenServiceTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.ModelGardenService", "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(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..18a6511e177c3 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..6eb38cbbb6b55 100644 --- a/google/cloud/aiplatform/v1/internal/model_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/model_logging_decorator.cc @@ -380,6 +380,119 @@ 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_); +} + +StatusOr +ModelServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ModelServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ModelServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ModelServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ModelServiceLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(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..00ccb1079cae9 100644 --- a/google/cloud/aiplatform/v1/internal/model_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/model_logging_decorator.h @@ -177,6 +177,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..374743c7624d9 100644 --- a/google/cloud/aiplatform/v1/internal/model_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/model_metadata_decorator.cc @@ -282,6 +282,91 @@ 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); +} + +StatusOr +ModelServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr ModelServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status ModelServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status ModelServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +StatusOr ModelServiceMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(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..9cf6cf3bc0e1c 100644 --- a/google/cloud/aiplatform/v1/internal/model_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/model_metadata_decorator.h @@ -177,6 +177,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..3ee906bb552c1 100644 --- a/google/cloud/aiplatform/v1/internal/model_stub.cc +++ b/google/cloud/aiplatform/v1/internal/model_stub.cc @@ -369,6 +369,121 @@ 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; +} + +StatusOr +DefaultModelServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultModelServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultModelServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultModelServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr DefaultModelServiceStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&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..1e0ba8c5062ea 100644 --- a/google/cloud/aiplatform/v1/internal/model_stub.h +++ b/google/cloud/aiplatform/v1/internal/model_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -173,6 +175,48 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -192,9 +236,18 @@ class DefaultModelServiceStub : public ModelServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::ModelService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +387,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -349,6 +442,11 @@ class DefaultModelServiceStub : public ModelServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..e047340579724 100644 --- a/google/cloud/aiplatform/v1/internal/model_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/model_stub_factory.cc @@ -29,6 +29,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultModelServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::ModelService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..f17ef91708a6a 100644 --- a/google/cloud/aiplatform/v1/internal/model_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/model_tracing_connection.cc @@ -337,6 +337,96 @@ 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)); +} + +StreamRange +ModelServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::ModelServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ModelServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("aiplatform_v1::ModelServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status ModelServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::ModelServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status ModelServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::ModelServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +StatusOr +ModelServiceTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::ModelServiceConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(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..568e4be317ddd 100644 --- a/google/cloud/aiplatform/v1/internal/model_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/model_tracing_connection.h @@ -168,6 +168,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..43bfaf37d995e 100644 --- a/google/cloud/aiplatform/v1/internal/model_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/model_tracing_stub.cc @@ -343,6 +343,120 @@ 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)); +} + +StatusOr +ModelServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.ModelService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr ModelServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.ModelService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status ModelServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.ModelService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status ModelServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.ModelService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +StatusOr ModelServiceTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.ModelService", + "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(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..1b0ed53fca157 100644 --- a/google/cloud/aiplatform/v1/internal/model_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/model_tracing_stub.h @@ -176,6 +176,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..cbf5fed6fec16 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/notebook_auth_decorator.cc @@ -345,6 +345,89 @@ 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); +} + +StatusOr +NotebookServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr NotebookServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status NotebookServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status NotebookServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +StatusOr NotebookServiceAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(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..a7badee8ea447 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/notebook_auth_decorator.h @@ -180,6 +180,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..952d4936dda30 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/notebook_connection_impl.cc @@ -1003,6 +1003,181 @@ 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__); +} + +StreamRange +NotebookServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +NotebookServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status NotebookServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status NotebookServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +NotebookServiceConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(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..25a0af630ec52 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/notebook_connection_impl.h @@ -200,6 +200,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..bde61d580162c 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/notebook_logging_decorator.cc @@ -403,6 +403,119 @@ 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_); +} + +StatusOr +NotebookServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr NotebookServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status NotebookServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status NotebookServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr NotebookServiceLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(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..c990f160f0d9e 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/notebook_logging_decorator.h @@ -180,6 +180,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..6c6d5b1de25d1 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/notebook_metadata_decorator.cc @@ -296,6 +296,92 @@ 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); +} + +StatusOr +NotebookServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr NotebookServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status NotebookServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status NotebookServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +StatusOr NotebookServiceMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(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..9810597d0e2a1 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/notebook_metadata_decorator.h @@ -181,6 +181,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..21829a6c1e6a0 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_stub.cc +++ b/google/cloud/aiplatform/v1/internal/notebook_stub.cc @@ -396,6 +396,123 @@ 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; +} + +StatusOr +DefaultNotebookServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultNotebookServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultNotebookServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultNotebookServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultNotebookServiceStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&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..704307472c46e 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_stub.h +++ b/google/cloud/aiplatform/v1/internal/notebook_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -188,6 +190,48 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -207,9 +251,18 @@ class DefaultNotebookServiceStub : public NotebookServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::NotebookService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateNotebookRuntimeTemplate( @@ -352,6 +405,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -367,6 +460,11 @@ class DefaultNotebookServiceStub : public NotebookServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..86e1072206436 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/notebook_stub_factory.cc @@ -29,6 +29,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultNotebookServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::NotebookService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..51139acaff616 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/notebook_tracing_connection.cc @@ -379,6 +379,98 @@ 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)); +} + +StreamRange +NotebookServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::NotebookServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +NotebookServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::NotebookServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status NotebookServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::NotebookServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status NotebookServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::NotebookServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +StatusOr +NotebookServiceTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::NotebookServiceConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(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..b1437497307be 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/notebook_tracing_connection.h @@ -188,6 +188,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..e39d486f59052 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/notebook_tracing_stub.cc @@ -373,6 +373,122 @@ 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)); +} + +StatusOr +NotebookServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.NotebookService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +NotebookServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.NotebookService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status NotebookServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.NotebookService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status NotebookServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.NotebookService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +StatusOr +NotebookServiceTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.NotebookService", "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(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..56221f06cad95 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/notebook_tracing_stub.h @@ -180,6 +180,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..27cdfe41dd900 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,92 @@ 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); +} + +StatusOr +PersistentResourceServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +PersistentResourceServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status PersistentResourceServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status PersistentResourceServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +StatusOr +PersistentResourceServiceAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(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..2a233cc812167 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..fc41ee21dea45 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,185 @@ 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__); +} + +StreamRange +PersistentResourceServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +PersistentResourceServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status PersistentResourceServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status PersistentResourceServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +PersistentResourceServiceConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(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..ff50567f084f1 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,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..b23e8d783ce50 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,124 @@ 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_); +} + +StatusOr +PersistentResourceServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +PersistentResourceServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status PersistentResourceServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status PersistentResourceServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +PersistentResourceServiceLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(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..dbcf0dadc5bbc 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..0d021f98800f6 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,96 @@ 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); +} + +StatusOr +PersistentResourceServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +PersistentResourceServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status PersistentResourceServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status PersistentResourceServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +StatusOr +PersistentResourceServiceMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(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..542bd95f2a16c 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..b1aa52f48f193 100644 --- a/google/cloud/aiplatform/v1/internal/persistent_resource_stub.cc +++ b/google/cloud/aiplatform/v1/internal/persistent_resource_stub.cc @@ -198,6 +198,125 @@ 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; +} + +StatusOr +DefaultPersistentResourceServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPersistentResourceServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultPersistentResourceServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultPersistentResourceServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultPersistentResourceServiceStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&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..6255f7484b74a 100644 --- a/google/cloud/aiplatform/v1/internal/persistent_resource_stub.h +++ b/google/cloud/aiplatform/v1/internal/persistent_resource_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -103,6 +105,48 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -123,9 +167,18 @@ class DefaultPersistentResourceServiceStub std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreatePersistentResource( @@ -191,6 +244,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -207,6 +300,11 @@ class DefaultPersistentResourceServiceStub std::unique_ptr< google::cloud::aiplatform::v1::PersistentResourceService::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..566c48c9dd466 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,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -46,9 +49,15 @@ CreateDefaultPersistentResourceServiceStub( auto service_grpc_stub = google::cloud::aiplatform::v1::PersistentResourceService::NewStub( channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..336ecf4a963d9 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,98 @@ 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)); +} + +StreamRange +PersistentResourceServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PersistentResourceServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +PersistentResourceServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PersistentResourceServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status PersistentResourceServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PersistentResourceServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status PersistentResourceServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PersistentResourceServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +StatusOr +PersistentResourceServiceTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PersistentResourceServiceConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(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..b22ae0c624ebe 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,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..120407fabb943 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,127 @@ 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)); +} + +StatusOr +PersistentResourceServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PersistentResourceService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +PersistentResourceServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PersistentResourceService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status PersistentResourceServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PersistentResourceService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status PersistentResourceServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PersistentResourceService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +StatusOr +PersistentResourceServiceTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PersistentResourceService", "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(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..e9297235108fb 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..685f70781763b 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/pipeline_auth_decorator.cc @@ -225,6 +225,89 @@ 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); +} + +StatusOr +PipelineServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr PipelineServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status PipelineServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status PipelineServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +StatusOr PipelineServiceAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(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..1e2fc3c621fb7 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/pipeline_auth_decorator.h @@ -129,6 +129,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..8be26d95ae376 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/pipeline_connection_impl.cc @@ -611,6 +611,181 @@ 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__); +} + +StreamRange +PipelineServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +PipelineServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status PipelineServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status PipelineServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +PipelineServiceConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(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..97aaa4ce5ab7a 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/pipeline_connection_impl.h @@ -144,6 +144,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..80c486868ad56 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/pipeline_logging_decorator.cc @@ -278,6 +278,119 @@ 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_); +} + +StatusOr +PipelineServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr PipelineServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status PipelineServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status PipelineServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr PipelineServiceLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(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..09f98eef8af1a 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/pipeline_logging_decorator.h @@ -129,6 +129,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..72dcad2df4f2c 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/pipeline_metadata_decorator.cc @@ -207,6 +207,92 @@ 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); +} + +StatusOr +PipelineServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr PipelineServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status PipelineServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status PipelineServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +StatusOr PipelineServiceMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(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..9c368c2ea2942 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/pipeline_metadata_decorator.h @@ -130,6 +130,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..9fab9c8e8e592 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_stub.cc +++ b/google/cloud/aiplatform/v1/internal/pipeline_stub.cc @@ -265,6 +265,123 @@ 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; +} + +StatusOr +DefaultPipelineServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPipelineServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultPipelineServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultPipelineServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultPipelineServiceStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&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..f6ad9b97da134 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_stub.h +++ b/google/cloud/aiplatform/v1/internal/pipeline_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -133,6 +135,48 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -152,9 +196,18 @@ class DefaultPipelineServiceStub : public PipelineServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::PipelineService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr CreateTrainingPipeline( @@ -246,6 +299,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -261,6 +354,11 @@ class DefaultPipelineServiceStub : public PipelineServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..fe230354bccf5 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/pipeline_stub_factory.cc @@ -29,6 +29,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultPipelineServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::PipelineService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..2e9ecea13af50 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/pipeline_tracing_connection.cc @@ -240,6 +240,98 @@ 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)); +} + +StreamRange +PipelineServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PipelineServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +PipelineServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PipelineServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status PipelineServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PipelineServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status PipelineServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PipelineServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +StatusOr +PipelineServiceTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PipelineServiceConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(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..396c815a836d8 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/pipeline_tracing_connection.h @@ -132,6 +132,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..fed723308c89f 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/pipeline_tracing_stub.cc @@ -248,6 +248,122 @@ 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)); +} + +StatusOr +PipelineServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PipelineService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +PipelineServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PipelineService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status PipelineServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PipelineService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status PipelineServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PipelineService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +StatusOr +PipelineServiceTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PipelineService", "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(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..e20c8b9259cea 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/pipeline_tracing_stub.h @@ -129,6 +129,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..8d5ddeb282565 100644 --- a/google/cloud/aiplatform/v1/internal/prediction_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/prediction_auth_decorator.cc @@ -197,6 +197,89 @@ 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); +} + +StatusOr +PredictionServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr PredictionServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status PredictionServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status PredictionServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +StatusOr PredictionServiceAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(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..b5749c942efdc 100644 --- a/google/cloud/aiplatform/v1/internal/prediction_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/prediction_auth_decorator.h @@ -118,6 +118,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..8e2a30633ab6e 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,181 @@ 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__); +} + +StreamRange +PredictionServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +PredictionServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status PredictionServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status PredictionServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +PredictionServiceConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(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..b3eca76b70611 100644 --- a/google/cloud/aiplatform/v1/internal/prediction_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/prediction_connection_impl.h @@ -117,6 +117,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..39a96e27fcdef 100644 --- a/google/cloud/aiplatform/v1/internal/prediction_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/prediction_logging_decorator.cc @@ -280,6 +280,121 @@ 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_); +} + +StatusOr +PredictionServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr PredictionServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status PredictionServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status PredictionServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +PredictionServiceLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(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..b4901673a52d7 100644 --- a/google/cloud/aiplatform/v1/internal/prediction_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/prediction_logging_decorator.h @@ -118,6 +118,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..7cc175bb78815 100644 --- a/google/cloud/aiplatform/v1/internal/prediction_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/prediction_metadata_decorator.cc @@ -182,6 +182,94 @@ 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); +} + +StatusOr +PredictionServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +PredictionServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status PredictionServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status PredictionServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +StatusOr +PredictionServiceMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(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..37f1dd87e0301 100644 --- a/google/cloud/aiplatform/v1/internal/prediction_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/prediction_metadata_decorator.h @@ -119,6 +119,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..dbb9340a8e57d 100644 --- a/google/cloud/aiplatform/v1/internal/prediction_stub.cc +++ b/google/cloud/aiplatform/v1/internal/prediction_stub.cc @@ -199,6 +199,123 @@ 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; +} + +StatusOr +DefaultPredictionServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPredictionServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultPredictionServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultPredictionServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultPredictionServiceStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&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..e105f1c605337 100644 --- a/google/cloud/aiplatform/v1/internal/prediction_stub.h +++ b/google/cloud/aiplatform/v1/internal/prediction_stub.h @@ -26,6 +26,9 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include #include #include @@ -115,6 +118,48 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; }; class DefaultPredictionServiceStub : public PredictionServiceStub { @@ -122,8 +167,16 @@ 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 + operations_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr Predict( grpc::ClientContext& context, Options const& options, @@ -205,10 +258,55 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + private: std::unique_ptr< google::cloud::aiplatform::v1::PredictionService::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..28d1d4221ad0a 100644 --- a/google/cloud/aiplatform/v1/internal/prediction_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/prediction_stub_factory.cc @@ -29,6 +29,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultPredictionServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::PredictionService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..be73e408f1233 100644 --- a/google/cloud/aiplatform/v1/internal/prediction_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/prediction_tracing_connection.cc @@ -146,6 +146,98 @@ 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)); +} + +StreamRange +PredictionServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PredictionServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +PredictionServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PredictionServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status PredictionServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PredictionServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status PredictionServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PredictionServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +StatusOr +PredictionServiceTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PredictionServiceConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(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..daa83db2704fe 100644 --- a/google/cloud/aiplatform/v1/internal/prediction_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/prediction_tracing_connection.h @@ -95,6 +95,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..9ec4813751590 100644 --- a/google/cloud/aiplatform/v1/internal/prediction_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/prediction_tracing_stub.cc @@ -221,6 +221,122 @@ 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)); +} + +StatusOr +PredictionServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PredictionService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +PredictionServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PredictionService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status PredictionServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PredictionService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status PredictionServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PredictionService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +StatusOr +PredictionServiceTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PredictionService", "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(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..1f471c8af3e39 100644 --- a/google/cloud/aiplatform/v1/internal/prediction_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/prediction_tracing_stub.h @@ -119,6 +119,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..22ebeb51fce0e 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/schedule_auth_decorator.cc @@ -111,6 +111,89 @@ 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); +} + +StatusOr +ScheduleServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr ScheduleServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status ScheduleServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status ScheduleServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +StatusOr ScheduleServiceAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(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..491fc533077b0 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/schedule_auth_decorator.h @@ -81,6 +81,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..be65dbbd7527d 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/schedule_connection_impl.cc @@ -266,6 +266,181 @@ 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__); +} + +StreamRange +ScheduleServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ScheduleServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ScheduleServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ScheduleServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +ScheduleServiceConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(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..dae0584614b4a 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/schedule_connection_impl.h @@ -87,6 +87,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..65d4b515936b9 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/schedule_logging_decorator.cc @@ -141,6 +141,119 @@ 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_); +} + +StatusOr +ScheduleServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ScheduleServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ScheduleServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ScheduleServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ScheduleServiceLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(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..c1a20787aed2b 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/schedule_logging_decorator.h @@ -81,6 +81,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..f4d9db5703795 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/schedule_metadata_decorator.cc @@ -118,6 +118,92 @@ 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); +} + +StatusOr +ScheduleServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr ScheduleServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status ScheduleServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status ScheduleServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +StatusOr ScheduleServiceMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(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..1cb9f44a5e97f 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/schedule_metadata_decorator.h @@ -82,6 +82,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..abcddd641eeed 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_stub.cc +++ b/google/cloud/aiplatform/v1/internal/schedule_stub.cc @@ -132,6 +132,123 @@ 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; +} + +StatusOr +DefaultScheduleServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultScheduleServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultScheduleServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultScheduleServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultScheduleServiceStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&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..256f92408a473 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_stub.h +++ b/google/cloud/aiplatform/v1/internal/schedule_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,48 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -92,9 +136,18 @@ class DefaultScheduleServiceStub : public ScheduleServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::ScheduleService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +191,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -153,6 +246,11 @@ class DefaultScheduleServiceStub : public ScheduleServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..bcf6025039366 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/schedule_stub_factory.cc @@ -29,6 +29,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultScheduleServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::ScheduleService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..f025448a5b62a 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/schedule_tracing_connection.cc @@ -116,6 +116,98 @@ 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)); +} + +StreamRange +ScheduleServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::ScheduleServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ScheduleServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::ScheduleServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status ScheduleServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::ScheduleServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status ScheduleServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::ScheduleServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +StatusOr +ScheduleServiceTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::ScheduleServiceConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(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..25a6f339c2e48 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/schedule_tracing_connection.h @@ -75,6 +75,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..9caf9919b78f0 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/schedule_tracing_stub.cc @@ -129,6 +129,122 @@ 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)); +} + +StatusOr +ScheduleServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.ScheduleService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +ScheduleServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.ScheduleService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status ScheduleServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.ScheduleService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status ScheduleServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.ScheduleService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +StatusOr +ScheduleServiceTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.ScheduleService", "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(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..f3e80a81d77b1 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/schedule_tracing_stub.h @@ -81,6 +81,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..c60d355f50100 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,92 @@ 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); +} + +StatusOr +SpecialistPoolServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +SpecialistPoolServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status SpecialistPoolServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status SpecialistPoolServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +StatusOr +SpecialistPoolServiceAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(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..4a406c5f7d082 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..d657ca250bc0a 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,183 @@ 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__); +} + +StreamRange +SpecialistPoolServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +SpecialistPoolServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status SpecialistPoolServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status SpecialistPoolServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +SpecialistPoolServiceConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(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..8e3a3f117818b 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,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..982e6a3bab8e2 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,122 @@ 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_); +} + +StatusOr +SpecialistPoolServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +SpecialistPoolServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status SpecialistPoolServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status SpecialistPoolServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +SpecialistPoolServiceLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(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..2be66816765af 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..7574d8989b9d2 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,94 @@ 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); +} + +StatusOr +SpecialistPoolServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +SpecialistPoolServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status SpecialistPoolServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status SpecialistPoolServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +StatusOr +SpecialistPoolServiceMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(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..64a29fe777d6d 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..95727327a2b10 100644 --- a/google/cloud/aiplatform/v1/internal/specialist_pool_stub.cc +++ b/google/cloud/aiplatform/v1/internal/specialist_pool_stub.cc @@ -148,6 +148,125 @@ 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; +} + +StatusOr +DefaultSpecialistPoolServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultSpecialistPoolServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultSpecialistPoolServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultSpecialistPoolServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultSpecialistPoolServiceStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&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..afd14dbe05b8b 100644 --- a/google/cloud/aiplatform/v1/internal/specialist_pool_stub.h +++ b/google/cloud/aiplatform/v1/internal/specialist_pool_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -89,6 +91,48 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -108,9 +152,18 @@ class DefaultSpecialistPoolServiceStub : public SpecialistPoolServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::SpecialistPoolService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +212,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -175,6 +268,11 @@ class DefaultSpecialistPoolServiceStub : public SpecialistPoolServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::SpecialistPoolService::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..8f8af11853d9c 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,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -45,9 +48,15 @@ CreateDefaultSpecialistPoolServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::SpecialistPoolService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..3b05bdbcb8d82 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,98 @@ 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)); +} + +StreamRange +SpecialistPoolServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::SpecialistPoolServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +SpecialistPoolServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::SpecialistPoolServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status SpecialistPoolServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::SpecialistPoolServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status SpecialistPoolServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::SpecialistPoolServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +StatusOr +SpecialistPoolServiceTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::SpecialistPoolServiceConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(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..14835ac33192e 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,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..a83e32d22d736 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,124 @@ 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)); +} + +StatusOr +SpecialistPoolServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.SpecialistPoolService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +SpecialistPoolServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.SpecialistPoolService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status SpecialistPoolServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.SpecialistPoolService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status SpecialistPoolServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.SpecialistPoolService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +StatusOr +SpecialistPoolServiceTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.SpecialistPoolService", "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(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..8e12b6b0d78d0 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,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..670ccaa7104cb 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/tensorboard_auth_decorator.cc @@ -446,6 +446,89 @@ 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); +} + +StatusOr +TensorboardServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr TensorboardServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status TensorboardServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status TensorboardServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +StatusOr TensorboardServiceAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(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..d368603c0115e 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/tensorboard_auth_decorator.h @@ -257,6 +257,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..b3cfbedb37a1f 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/tensorboard_connection_impl.cc @@ -1132,6 +1132,183 @@ 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__); +} + +StreamRange +TensorboardServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +TensorboardServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status TensorboardServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status TensorboardServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +TensorboardServiceConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(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..aa7acdf469c75 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/tensorboard_connection_impl.h @@ -254,6 +254,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..ddc000d245b4a 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/tensorboard_logging_decorator.cc @@ -586,6 +586,122 @@ 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_); +} + +StatusOr +TensorboardServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +TensorboardServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status TensorboardServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status TensorboardServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +TensorboardServiceLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(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..4be5647485a56 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/tensorboard_logging_decorator.h @@ -257,6 +257,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..7b9322c7e8b2c 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/tensorboard_metadata_decorator.cc @@ -428,6 +428,94 @@ 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); +} + +StatusOr +TensorboardServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +TensorboardServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status TensorboardServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status TensorboardServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +StatusOr +TensorboardServiceMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(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..8c435cb1f9c95 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/tensorboard_metadata_decorator.h @@ -258,6 +258,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..e824abde28c39 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_stub.cc +++ b/google/cloud/aiplatform/v1/internal/tensorboard_stub.cc @@ -549,6 +549,123 @@ 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; +} + +StatusOr +DefaultTensorboardServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultTensorboardServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultTensorboardServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultTensorboardServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultTensorboardServiceStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&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..d8b7f423997c3 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_stub.h +++ b/google/cloud/aiplatform/v1/internal/tensorboard_stub.h @@ -26,6 +26,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -268,6 +270,48 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -287,9 +331,18 @@ class DefaultTensorboardServiceStub : public TensorboardServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::TensorboardService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +562,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -525,6 +618,11 @@ class DefaultTensorboardServiceStub : public TensorboardServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::TensorboardService::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..3068552e997f5 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/tensorboard_stub_factory.cc @@ -29,6 +29,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultTensorboardServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::TensorboardService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..d6bc9ec2ec262 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/tensorboard_tracing_connection.cc @@ -490,6 +490,98 @@ 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)); +} + +StreamRange +TensorboardServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::TensorboardServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +TensorboardServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::TensorboardServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status TensorboardServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::TensorboardServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status TensorboardServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::TensorboardServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +StatusOr +TensorboardServiceTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::TensorboardServiceConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(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..824973f4ea846 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/tensorboard_tracing_connection.h @@ -237,6 +237,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..55276a5e7514a 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/tensorboard_tracing_stub.cc @@ -545,6 +545,122 @@ 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)); +} + +StatusOr +TensorboardServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.TensorboardService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +TensorboardServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.TensorboardService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status TensorboardServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.TensorboardService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status TensorboardServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.TensorboardService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +StatusOr +TensorboardServiceTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.TensorboardService", "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(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..5c9b863789d6a 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/tensorboard_tracing_stub.h @@ -257,6 +257,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..6805d476d2485 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/vizier_auth_decorator.cc @@ -198,6 +198,89 @@ 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); +} + +StatusOr +VizierServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr VizierServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status VizierServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status VizierServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +StatusOr VizierServiceAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(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..afef20b19185a 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/vizier_auth_decorator.h @@ -124,6 +124,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..65109786755bb 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/vizier_connection_impl.cc @@ -479,6 +479,181 @@ 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__); +} + +StreamRange +VizierServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +VizierServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status VizierServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status VizierServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +VizierServiceConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(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..223676940fa04 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/vizier_connection_impl.h @@ -126,6 +126,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..1e1bf57902070 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/vizier_logging_decorator.cc @@ -254,6 +254,119 @@ 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_); +} + +StatusOr +VizierServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr VizierServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status VizierServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status VizierServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr VizierServiceLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(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..2de7fbe6b4b78 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/vizier_logging_decorator.h @@ -124,6 +124,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..ff7f1960111a0 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/vizier_metadata_decorator.cc @@ -202,6 +202,91 @@ 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); +} + +StatusOr +VizierServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr VizierServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status VizierServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status VizierServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +StatusOr VizierServiceMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(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..186deaf547ecd 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/vizier_metadata_decorator.h @@ -124,6 +124,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..40a980907c2a7 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_stub.cc +++ b/google/cloud/aiplatform/v1/internal/vizier_stub.cc @@ -250,6 +250,122 @@ 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; +} + +StatusOr +DefaultVizierServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultVizierServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultVizierServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultVizierServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultVizierServiceStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&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..a317c046ed56f 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_stub.h +++ b/google/cloud/aiplatform/v1/internal/vizier_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,48 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -137,9 +181,18 @@ class DefaultVizierServiceStub : public VizierServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::VizierService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +279,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -241,6 +334,11 @@ class DefaultVizierServiceStub : public VizierServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..0dc2c34c22d6d 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/vizier_stub_factory.cc @@ -29,6 +29,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultVizierServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::VizierService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..c409ce92dee41 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/vizier_tracing_connection.cc @@ -215,6 +215,96 @@ 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)); +} + +StreamRange +VizierServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::VizierServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +VizierServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::VizierServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status VizierServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::VizierServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status VizierServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::VizierServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +StatusOr +VizierServiceTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::VizierServiceConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(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..38b4a4a1d638a 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/vizier_tracing_connection.h @@ -114,6 +114,36 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..76c9aa7f8c077 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/vizier_tracing_stub.cc @@ -242,6 +242,121 @@ 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)); +} + +StatusOr +VizierServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.VizierService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr VizierServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.VizierService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status VizierServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.VizierService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status VizierServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.VizierService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +StatusOr +VizierServiceTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.VizierService", + "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(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..f2cb2ec0c94c4 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/vizier_tracing_stub.h @@ -123,6 +123,46 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..6123747683d56 100644 --- a/google/cloud/aiplatform/v1/job_client.cc +++ b/google/cloud/aiplatform/v1/job_client.cc @@ -830,6 +830,100 @@ 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); +} + +StreamRange JobServiceClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange JobServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr JobServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr JobServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status JobServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status JobServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status JobServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status JobServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +StatusOr JobServiceClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(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 c7287e204232b..9d9494b1060b6 100644 --- a/google/cloud/aiplatform/v1/job_client.h +++ b/google/cloud/aiplatform/v1/job_client.h @@ -2840,6 +2840,497 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..2dd7536d55413 100644 --- a/google/cloud/aiplatform/v1/job_connection.cc +++ b/google/cloud/aiplatform/v1/job_connection.cc @@ -385,6 +385,63 @@ 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"); +} + +StreamRange +JobServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr JobServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status JobServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status JobServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr JobServiceConnection::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeJobServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..fffcd693adb6a 100644 --- a/google/cloud/aiplatform/v1/job_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/job_connection_idempotency_policy.cc @@ -232,6 +232,57 @@ 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; +} + +Idempotency JobServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency JobServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency JobServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency JobServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency JobServiceConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..69814e5a459c0 100644 --- a/google/cloud/aiplatform/v1/job_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/job_connection_idempotency_policy.h @@ -22,6 +22,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -161,6 +164,36 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest 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..6e563ced834a6 100644 --- a/google/cloud/aiplatform/v1/llm_utility_client.cc +++ b/google/cloud/aiplatform/v1/llm_utility_client.cc @@ -70,6 +70,105 @@ 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); +} + +StreamRange +LlmUtilityServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +LlmUtilityServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr LlmUtilityServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr LlmUtilityServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status LlmUtilityServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status LlmUtilityServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status LlmUtilityServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status LlmUtilityServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +StatusOr LlmUtilityServiceClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(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 7603c773b035b..518b148bbc9fc 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,497 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..af0716b177bf2 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,66 @@ 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"); +} + +StreamRange +LlmUtilityServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +LlmUtilityServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status LlmUtilityServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status LlmUtilityServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +LlmUtilityServiceConnection::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeLlmUtilityServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions #include @@ -189,6 +190,36 @@ 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..835bc5c05ee4f 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,57 @@ 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; +} + +Idempotency LlmUtilityServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency LlmUtilityServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency LlmUtilityServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency LlmUtilityServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency LlmUtilityServiceConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..dc9d95c02a6c6 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,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -42,6 +45,36 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest 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..014ea5397b8bb 100644 --- a/google/cloud/aiplatform/v1/match_client.cc +++ b/google/cloud/aiplatform/v1/match_client.cc @@ -48,6 +48,101 @@ 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); +} + +StreamRange MatchServiceClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange MatchServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr MatchServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr MatchServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status MatchServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status MatchServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status MatchServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status MatchServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +StatusOr MatchServiceClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(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..36530b0370bb8 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,497 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..31e012023c9fe 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,63 @@ 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"); +} + +StreamRange +MatchServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr MatchServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status MatchServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status MatchServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr MatchServiceConnection::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeMatchServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions #include @@ -189,6 +190,36 @@ 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..1af78ed69652e 100644 --- a/google/cloud/aiplatform/v1/match_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/match_connection_idempotency_policy.cc @@ -44,6 +44,57 @@ 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; +} + +Idempotency MatchServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency MatchServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency MatchServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency MatchServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency MatchServiceConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..3fdd966b0e886 100644 --- a/google/cloud/aiplatform/v1/match_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/match_connection_idempotency_policy.h @@ -22,6 +22,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -42,6 +45,36 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest 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..4751a0aab9dac 100644 --- a/google/cloud/aiplatform/v1/metadata_client.cc +++ b/google/cloud/aiplatform/v1/metadata_client.cc @@ -802,6 +802,103 @@ 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); +} + +StreamRange +MetadataServiceClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +MetadataServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr MetadataServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr MetadataServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status MetadataServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status MetadataServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status MetadataServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status MetadataServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +StatusOr MetadataServiceClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(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..9a8bba0f1f51a 100644 --- a/google/cloud/aiplatform/v1/metadata_client.h +++ b/google/cloud/aiplatform/v1/metadata_client.h @@ -2653,6 +2653,497 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..4dc6a10b91fdf 100644 --- a/google/cloud/aiplatform/v1/metadata_connection.cc +++ b/google/cloud/aiplatform/v1/metadata_connection.cc @@ -383,6 +383,66 @@ 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"); +} + +StreamRange +MetadataServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +MetadataServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status MetadataServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status MetadataServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +MetadataServiceConnection::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeMetadataServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..c4e2b4a85bda4 100644 --- a/google/cloud/aiplatform/v1/metadata_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/metadata_connection_idempotency_policy.cc @@ -200,6 +200,57 @@ 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; +} + +Idempotency MetadataServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency MetadataServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency MetadataServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency MetadataServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency MetadataServiceConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..cc88b3f5bf6b4 100644 --- a/google/cloud/aiplatform/v1/metadata_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/metadata_connection_idempotency_policy.h @@ -22,6 +22,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -138,6 +141,36 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest 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..cf25a4f7c8a2e 100644 --- a/google/cloud/aiplatform/v1/migration_client.cc +++ b/google/cloud/aiplatform/v1/migration_client.cc @@ -101,6 +101,104 @@ 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); +} + +StreamRange +MigrationServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +MigrationServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr MigrationServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr MigrationServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status MigrationServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status MigrationServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status MigrationServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status MigrationServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +StatusOr MigrationServiceClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(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..d289c6e7c2a08 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,497 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..8143569edf43e 100644 --- a/google/cloud/aiplatform/v1/migration_connection.cc +++ b/google/cloud/aiplatform/v1/migration_connection.cc @@ -70,6 +70,66 @@ 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"); +} + +StreamRange +MigrationServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +MigrationServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status MigrationServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status MigrationServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +MigrationServiceConnection::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeMigrationServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions> 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..2b135598130f3 100644 --- a/google/cloud/aiplatform/v1/migration_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/migration_connection_idempotency_policy.cc @@ -46,6 +46,57 @@ 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; +} + +Idempotency MigrationServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency MigrationServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency MigrationServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency MigrationServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency MigrationServiceConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..228a4dfb989b3 100644 --- a/google/cloud/aiplatform/v1/migration_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/migration_connection_idempotency_policy.h @@ -22,6 +22,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -43,6 +46,36 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest 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..3abff6820d4ab 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_dataset_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_dataset_connection.h @@ -421,6 +421,46 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest 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..e543e9c22fa06 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,46 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest 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..ddb0a4a5e980f 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_endpoint_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_endpoint_connection.h @@ -262,6 +262,46 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest 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..8601aac7be249 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,46 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest 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..4d919674907de 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,46 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest 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..83e7e3c65583e 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,46 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest 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..0c2112c076267 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_featurestore_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_featurestore_connection.h @@ -581,6 +581,46 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest 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..81eb59c911c97 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,46 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest 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..9db37b61d2f33 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,46 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest 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..1a7cfc4f001d9 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_index_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_index_connection.h @@ -182,6 +182,46 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest 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..2e295fe523b12 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,46 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest 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..22dcc29df8d4f 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_job_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_job_connection.h @@ -505,6 +505,46 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest 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..f5d3b5d13a1a7 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,46 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest 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..525b8d080d2f5 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_match_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_match_connection.h @@ -59,6 +59,46 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest 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..f68330500743d 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_metadata_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_metadata_connection.h @@ -502,6 +502,46 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest 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..0ac0421556299 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_migration_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_migration_connection.h @@ -96,6 +96,46 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest 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..a7af5a05535d8 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_model_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_model_connection.h @@ -359,6 +359,46 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest 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..16f6e342b3d25 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,46 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest 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..0c1cd4eb76c0f 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_notebook_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_notebook_connection.h @@ -431,6 +431,46 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest 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..54b1efffcff96 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,46 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest 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..70fb039c4b1b3 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_pipeline_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_pipeline_connection.h @@ -263,6 +263,46 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest 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..6a8d9bec23fce 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_prediction_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_prediction_connection.h @@ -116,6 +116,46 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest 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..1ede54c7d159e 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_schedule_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_schedule_connection.h @@ -116,6 +116,46 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest 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..9487ad2f82b64 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,46 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest 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..e2c5fe0e464f4 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_tensorboard_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_tensorboard_connection.h @@ -453,6 +453,46 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest 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..431b853347f93 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_vizier_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_vizier_connection.h @@ -193,6 +193,46 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest 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..1657f00d32408 100644 --- a/google/cloud/aiplatform/v1/model_client.cc +++ b/google/cloud/aiplatform/v1/model_client.cc @@ -512,6 +512,101 @@ 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); +} + +StreamRange ModelServiceClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange ModelServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr ModelServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr ModelServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status ModelServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status ModelServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status ModelServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status ModelServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +StatusOr ModelServiceClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(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..7180b3c09c58a 100644 --- a/google/cloud/aiplatform/v1/model_client.h +++ b/google/cloud/aiplatform/v1/model_client.h @@ -1681,6 +1681,497 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..9b55d1c3649f3 100644 --- a/google/cloud/aiplatform/v1/model_connection.cc +++ b/google/cloud/aiplatform/v1/model_connection.cc @@ -254,6 +254,63 @@ 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"); +} + +StreamRange +ModelServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr ModelServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ModelServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ModelServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr ModelServiceConnection::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeModelServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..c30412330d097 100644 --- a/google/cloud/aiplatform/v1/model_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/model_connection_idempotency_policy.cc @@ -129,6 +129,57 @@ 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; +} + +Idempotency ModelServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ModelServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ModelServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency ModelServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency ModelServiceConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..2ef363275aedd 100644 --- a/google/cloud/aiplatform/v1/model_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/model_connection_idempotency_policy.h @@ -22,6 +22,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -95,6 +98,36 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest 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..91c849d6a5273 100644 --- a/google/cloud/aiplatform/v1/model_garden_client.cc +++ b/google/cloud/aiplatform/v1/model_garden_client.cc @@ -49,6 +49,106 @@ 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); +} + +StreamRange +ModelGardenServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +ModelGardenServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr ModelGardenServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr ModelGardenServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status ModelGardenServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status ModelGardenServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status ModelGardenServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status ModelGardenServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +StatusOr +ModelGardenServiceClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(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..418ef7c1db04e 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,497 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..694f937166ccc 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,66 @@ 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"); +} + +StreamRange +ModelGardenServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +ModelGardenServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ModelGardenServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ModelGardenServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +ModelGardenServiceConnection::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeModelGardenServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions #include @@ -188,6 +189,36 @@ 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..0039631fb98d6 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,57 @@ 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; +} + +Idempotency ModelGardenServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ModelGardenServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ModelGardenServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency ModelGardenServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency ModelGardenServiceConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..d4f079e30fffd 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,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -39,6 +42,36 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest 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..758f8d894e049 100644 --- a/google/cloud/aiplatform/v1/notebook_client.cc +++ b/google/cloud/aiplatform/v1/notebook_client.cc @@ -536,6 +536,103 @@ 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); +} + +StreamRange +NotebookServiceClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +NotebookServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr NotebookServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr NotebookServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status NotebookServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status NotebookServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status NotebookServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status NotebookServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +StatusOr NotebookServiceClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(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 7ec070795bfa2..f7e0be4f8c16e 100644 --- a/google/cloud/aiplatform/v1/notebook_client.h +++ b/google/cloud/aiplatform/v1/notebook_client.h @@ -1539,6 +1539,497 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..98732a53a7aff 100644 --- a/google/cloud/aiplatform/v1/notebook_connection.cc +++ b/google/cloud/aiplatform/v1/notebook_connection.cc @@ -281,6 +281,66 @@ 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"); +} + +StreamRange +NotebookServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +NotebookServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status NotebookServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status NotebookServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +NotebookServiceConnection::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeNotebookServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions> 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..a5ed2d417b457 100644 --- a/google/cloud/aiplatform/v1/notebook_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/notebook_connection_idempotency_policy.cc @@ -122,6 +122,57 @@ 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; +} + +Idempotency NotebookServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency NotebookServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency NotebookServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency NotebookServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency NotebookServiceConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..bbe22a3d8fe78 100644 --- a/google/cloud/aiplatform/v1/notebook_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/notebook_connection_idempotency_policy.h @@ -22,6 +22,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -93,6 +96,36 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest 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..adbe8897d8034 100644 --- a/google/cloud/aiplatform/v1/persistent_resource_client.cc +++ b/google/cloud/aiplatform/v1/persistent_resource_client.cc @@ -260,6 +260,108 @@ 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); +} + +StreamRange +PersistentResourceServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +PersistentResourceServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +PersistentResourceServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +PersistentResourceServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status PersistentResourceServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status PersistentResourceServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status PersistentResourceServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status PersistentResourceServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +StatusOr +PersistentResourceServiceClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(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..d7b76ba13ab75 100644 --- a/google/cloud/aiplatform/v1/persistent_resource_client.h +++ b/google/cloud/aiplatform/v1/persistent_resource_client.h @@ -722,6 +722,497 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..0a8aa54ad162b 100644 --- a/google/cloud/aiplatform/v1/persistent_resource_connection.cc +++ b/google/cloud/aiplatform/v1/persistent_resource_connection.cc @@ -149,6 +149,68 @@ 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"); +} + +StreamRange +PersistentResourceServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +PersistentResourceServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status PersistentResourceServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status PersistentResourceServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +PersistentResourceServiceConnection::WaitOperation( + google::longrunning::WaitOperationRequest 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..6dac0171625ec 100644 --- a/google/cloud/aiplatform/v1/persistent_resource_connection.h +++ b/google/cloud/aiplatform/v1/persistent_resource_connection.h @@ -263,6 +263,36 @@ 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..fdda2bce116ac 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,61 @@ 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; +} + +Idempotency +PersistentResourceServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency PersistentResourceServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +PersistentResourceServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency +PersistentResourceServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency PersistentResourceServiceConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..835dfcbe513aa 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,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -59,6 +62,36 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest 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..e7419aaffbcf4 100644 --- a/google/cloud/aiplatform/v1/pipeline_client.cc +++ b/google/cloud/aiplatform/v1/pipeline_client.cc @@ -351,6 +351,103 @@ 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); +} + +StreamRange +PipelineServiceClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +PipelineServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr PipelineServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr PipelineServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status PipelineServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status PipelineServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status PipelineServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status PipelineServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +StatusOr PipelineServiceClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(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..ad8c0ef6283bf 100644 --- a/google/cloud/aiplatform/v1/pipeline_client.h +++ b/google/cloud/aiplatform/v1/pipeline_client.h @@ -1161,6 +1161,497 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..e84947498c038 100644 --- a/google/cloud/aiplatform/v1/pipeline_connection.cc +++ b/google/cloud/aiplatform/v1/pipeline_connection.cc @@ -184,6 +184,66 @@ 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"); +} + +StreamRange +PipelineServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +PipelineServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status PipelineServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status PipelineServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +PipelineServiceConnection::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakePipelineServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions> 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..9de519371bec8 100644 --- a/google/cloud/aiplatform/v1/pipeline_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/pipeline_connection_idempotency_policy.cc @@ -94,6 +94,57 @@ 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; +} + +Idempotency PipelineServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency PipelineServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency PipelineServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency PipelineServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency PipelineServiceConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..9d11d229dbe82 100644 --- a/google/cloud/aiplatform/v1/pipeline_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/pipeline_connection_idempotency_policy.h @@ -22,6 +22,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -77,6 +80,36 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest 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..bb742716eeaea 100644 --- a/google/cloud/aiplatform/v1/prediction_client.cc +++ b/google/cloud/aiplatform/v1/prediction_client.cc @@ -206,6 +206,105 @@ 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); +} + +StreamRange +PredictionServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +PredictionServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr PredictionServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr PredictionServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status PredictionServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status PredictionServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status PredictionServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status PredictionServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +StatusOr PredictionServiceClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(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 4c1cd7b25b113..3f0c78e60dff8 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 @@ -780,6 +781,497 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..08c1fc1b753a8 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,66 @@ 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"); +} + +StreamRange +PredictionServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +PredictionServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status PredictionServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status PredictionServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +PredictionServiceConnection::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakePredictionServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..22eb9691dc0f9 100644 --- a/google/cloud/aiplatform/v1/prediction_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/prediction_connection_idempotency_policy.cc @@ -64,6 +64,57 @@ 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; +} + +Idempotency PredictionServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency PredictionServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency PredictionServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency PredictionServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency PredictionServiceConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..9aad27a694fe2 100644 --- a/google/cloud/aiplatform/v1/prediction_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/prediction_connection_idempotency_policy.h @@ -22,6 +22,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -54,6 +57,36 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest 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..7e38fff9c94c1 100644 --- a/google/cloud/aiplatform/v1/schedule_client.cc +++ b/google/cloud/aiplatform/v1/schedule_client.cc @@ -179,6 +179,103 @@ 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); +} + +StreamRange +ScheduleServiceClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +ScheduleServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr ScheduleServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr ScheduleServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status ScheduleServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status ScheduleServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status ScheduleServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status ScheduleServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +StatusOr ScheduleServiceClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(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..eafb5081c503d 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,497 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..c23be6675ced4 100644 --- a/google/cloud/aiplatform/v1/schedule_connection.cc +++ b/google/cloud/aiplatform/v1/schedule_connection.cc @@ -97,6 +97,66 @@ 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"); +} + +StreamRange +ScheduleServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +ScheduleServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ScheduleServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ScheduleServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +ScheduleServiceConnection::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeScheduleServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..57ff986c75b87 100644 --- a/google/cloud/aiplatform/v1/schedule_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/schedule_connection_idempotency_policy.cc @@ -69,6 +69,57 @@ 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; +} + +Idempotency ScheduleServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ScheduleServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ScheduleServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency ScheduleServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency ScheduleServiceConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..15e1a41e4869e 100644 --- a/google/cloud/aiplatform/v1/schedule_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/schedule_connection_idempotency_policy.h @@ -22,6 +22,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -57,6 +60,36 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest 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..78ec34086d0ea 100644 --- a/google/cloud/aiplatform/v1/specialist_pool_client.cc +++ b/google/cloud/aiplatform/v1/specialist_pool_client.cc @@ -204,6 +204,108 @@ 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); +} + +StreamRange +SpecialistPoolServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +SpecialistPoolServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +SpecialistPoolServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +SpecialistPoolServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status SpecialistPoolServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status SpecialistPoolServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status SpecialistPoolServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status SpecialistPoolServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +StatusOr +SpecialistPoolServiceClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(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..97881c7cf5233 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,497 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..35483344fbed7 100644 --- a/google/cloud/aiplatform/v1/specialist_pool_connection.cc +++ b/google/cloud/aiplatform/v1/specialist_pool_connection.cc @@ -124,6 +124,66 @@ 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"); +} + +StreamRange +SpecialistPoolServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +SpecialistPoolServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status SpecialistPoolServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status SpecialistPoolServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +SpecialistPoolServiceConnection::WaitOperation( + google::longrunning::WaitOperationRequest 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..91c4c39a7505b 100644 --- a/google/cloud/aiplatform/v1/specialist_pool_connection.h +++ b/google/cloud/aiplatform/v1/specialist_pool_connection.h @@ -241,6 +241,36 @@ 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..cce77629cdcf6 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,58 @@ 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; +} + +Idempotency SpecialistPoolServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SpecialistPoolServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency SpecialistPoolServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency SpecialistPoolServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency SpecialistPoolServiceConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..c21ee99f1bcdc 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,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -54,6 +57,36 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest 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..40e53c617888d 100644 --- a/google/cloud/aiplatform/v1/tensorboard_client.cc +++ b/google/cloud/aiplatform/v1/tensorboard_client.cc @@ -770,6 +770,106 @@ 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); +} + +StreamRange +TensorboardServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +TensorboardServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr TensorboardServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr TensorboardServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status TensorboardServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status TensorboardServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status TensorboardServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status TensorboardServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +StatusOr +TensorboardServiceClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(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..a4917889f75b2 100644 --- a/google/cloud/aiplatform/v1/tensorboard_client.h +++ b/google/cloud/aiplatform/v1/tensorboard_client.h @@ -2444,6 +2444,497 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..17af42eb38847 100644 --- a/google/cloud/aiplatform/v1/tensorboard_connection.cc +++ b/google/cloud/aiplatform/v1/tensorboard_connection.cc @@ -348,6 +348,66 @@ 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"); +} + +StreamRange +TensorboardServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +TensorboardServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status TensorboardServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status TensorboardServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +TensorboardServiceConnection::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeTensorboardServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..de9bf845ec5b0 100644 --- a/google/cloud/aiplatform/v1/tensorboard_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/tensorboard_connection_idempotency_policy.cc @@ -203,6 +203,57 @@ 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; +} + +Idempotency TensorboardServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency TensorboardServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency TensorboardServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency TensorboardServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency TensorboardServiceConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..de0b426880245 100644 --- a/google/cloud/aiplatform/v1/tensorboard_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/tensorboard_connection_idempotency_policy.h @@ -22,6 +22,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -142,6 +145,36 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest 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..0a09e25f3d931 100644 --- a/google/cloud/aiplatform/v1/vizier_client.cc +++ b/google/cloud/aiplatform/v1/vizier_client.cc @@ -260,6 +260,101 @@ 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); +} + +StreamRange VizierServiceClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange VizierServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr VizierServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr VizierServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status VizierServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status VizierServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status VizierServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status VizierServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +StatusOr VizierServiceClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(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..fd79ab7a96047 100644 --- a/google/cloud/aiplatform/v1/vizier_client.h +++ b/google/cloud/aiplatform/v1/vizier_client.h @@ -942,6 +942,497 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..3f048dde686ff 100644 --- a/google/cloud/aiplatform/v1/vizier_connection.cc +++ b/google/cloud/aiplatform/v1/vizier_connection.cc @@ -165,6 +165,64 @@ 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"); +} + +StreamRange +VizierServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr VizierServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status VizierServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status VizierServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr VizierServiceConnection::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeVizierServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..c509422fccd29 100644 --- a/google/cloud/aiplatform/v1/vizier_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/vizier_connection_idempotency_policy.cc @@ -110,6 +110,57 @@ 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; +} + +Idempotency VizierServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency VizierServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency VizierServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency VizierServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency VizierServiceConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..a94b8ebcfa0ec 100644 --- a/google/cloud/aiplatform/v1/vizier_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/vizier_connection_idempotency_policy.h @@ -22,6 +22,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -82,6 +85,36 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest 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..fd154e231f498 100644 --- a/google/cloud/alloydb/v1/alloy_db_admin_client.cc +++ b/google/cloud/alloydb/v1/alloy_db_admin_client.cc @@ -941,6 +941,76 @@ 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); +} + +StreamRange AlloyDBAdminClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange AlloyDBAdminClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr AlloyDBAdminClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr AlloyDBAdminClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status AlloyDBAdminClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status AlloyDBAdminClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status AlloyDBAdminClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status AlloyDBAdminClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..505397d11ae98 100644 --- a/google/cloud/alloydb/v1/alloy_db_admin_client.h +++ b/google/cloud/alloydb/v1/alloy_db_admin_client.h @@ -2905,6 +2905,356 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..536ecf6b63355 100644 --- a/google/cloud/alloydb/v1/alloy_db_admin_connection.cc +++ b/google/cloud/alloydb/v1/alloy_db_admin_connection.cc @@ -495,6 +495,42 @@ 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"); +} + +StreamRange +AlloyDBAdminConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr AlloyDBAdminConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AlloyDBAdminConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AlloyDBAdminConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeAlloyDBAdminConnection( Options options) { internal::CheckExpectedOptions ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..e17cc22637d35 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,36 @@ 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; +} + +Idempotency AlloyDBAdminConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AlloyDBAdminConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AlloyDBAdminConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AlloyDBAdminConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..b2d38d6c10d28 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -131,6 +133,24 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..9ed3e6ca542aa 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,56 @@ 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); +} + +StatusOr +AlloyDBAdminAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr AlloyDBAdminAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status AlloyDBAdminAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status AlloyDBAdminAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..2da17cdd87dac 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..953c2966da3a6 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,127 @@ 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__); +} + +StreamRange +AlloyDBAdminConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +AlloyDBAdminConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status AlloyDBAdminConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status AlloyDBAdminConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..25eb9a7882594 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..6660b9024321b 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,74 @@ 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_); +} + +StatusOr +AlloyDBAdminLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AlloyDBAdminLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AlloyDBAdminLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AlloyDBAdminLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..460b308dc77f8 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..3e4334bc393bf 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,56 @@ 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); +} + +StatusOr +AlloyDBAdminMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr AlloyDBAdminMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status AlloyDBAdminMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status AlloyDBAdminMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..fd38e9eedbd0b 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..7e849219ba3d3 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,75 @@ 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; +} + +StatusOr +DefaultAlloyDBAdminStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAlloyDBAdminStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultAlloyDBAdminStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultAlloyDBAdminStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..2364bc1625e8b 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,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -283,6 +284,31 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -301,9 +327,16 @@ class DefaultAlloyDBAdminStub : public AlloyDBAdminStub { DefaultAlloyDBAdminStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListClusters( grpc::ClientContext& context, Options const& options, @@ -556,6 +589,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -571,6 +628,10 @@ class DefaultAlloyDBAdminStub : public AlloyDBAdminStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..e554a9afda258 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,14 @@ std::shared_ptr CreateDefaultAlloyDBAdminStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::alloydb::v1::AlloyDBAdmin::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..c58b0f347c712 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,62 @@ 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)); +} + +StreamRange +AlloyDBAdminTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("alloydb_v1::AlloyDBAdminConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AlloyDBAdminTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("alloydb_v1::AlloyDBAdminConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status AlloyDBAdminTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = + internal::MakeSpan("alloydb_v1::AlloyDBAdminConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status AlloyDBAdminTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("alloydb_v1::AlloyDBAdminConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..dd63040585bbe 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..6d6e8f5376029 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,75 @@ 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)); +} + +StatusOr +AlloyDBAdminTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.alloydb.v1.AlloyDBAdmin", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr AlloyDBAdminTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.alloydb.v1.AlloyDBAdmin", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status AlloyDBAdminTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.alloydb.v1.AlloyDBAdmin", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status AlloyDBAdminTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.alloydb.v1.AlloyDBAdmin", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..8cec7bcd7f777 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..73708d8770ca1 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,29 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/apikeys/v2/api_keys_client.cc b/google/cloud/apikeys/v2/api_keys_client.cc index e93a0e93df4ff..a2e8234499141 100644 --- a/google/cloud/apikeys/v2/api_keys_client.cc +++ b/google/cloud/apikeys/v2/api_keys_client.cc @@ -217,6 +217,20 @@ StatusOr ApiKeysClient::LookupKey( return connection_->LookupKey(request); } +StatusOr ApiKeysClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr ApiKeysClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace apikeys_v2 } // namespace cloud diff --git a/google/cloud/apikeys/v2/api_keys_client.h b/google/cloud/apikeys/v2/api_keys_client.h index 9e72437ffda42..ab1afe1144515 100644 --- a/google/cloud/apikeys/v2/api_keys_client.h +++ b/google/cloud/apikeys/v2/api_keys_client.h @@ -778,6 +778,66 @@ class ApiKeysClient { google::api::apikeys::v2::LookupKeyRequest const& request, Options opts = {}); + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/apikeys/v2/api_keys_connection.cc b/google/cloud/apikeys/v2/api_keys_connection.cc index feffaad5dc23d..f5adf015b3cec 100644 --- a/google/cloud/apikeys/v2/api_keys_connection.cc +++ b/google/cloud/apikeys/v2/api_keys_connection.cc @@ -142,6 +142,11 @@ ApiKeysConnection::LookupKey( return Status(StatusCode::kUnimplemented, "not implemented"); } +StatusOr ApiKeysConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeApiKeysConnection(Options options) { internal::CheckExpectedOptions LookupKey( google::api::apikeys::v2::LookupKeyRequest const& request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/apikeys/v2/api_keys_connection_idempotency_policy.cc b/google/cloud/apikeys/v2/api_keys_connection_idempotency_policy.cc index 12abd8e80c683..b75b4420d7007 100644 --- a/google/cloud/apikeys/v2/api_keys_connection_idempotency_policy.cc +++ b/google/cloud/apikeys/v2/api_keys_connection_idempotency_policy.cc @@ -74,6 +74,11 @@ Idempotency ApiKeysConnectionIdempotencyPolicy::LookupKey( return Idempotency::kIdempotent; } +Idempotency ApiKeysConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultApiKeysConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/apikeys/v2/api_keys_connection_idempotency_policy.h b/google/cloud/apikeys/v2/api_keys_connection_idempotency_policy.h index a57d15feea0d6..ae88488a6f709 100644 --- a/google/cloud/apikeys/v2/api_keys_connection_idempotency_policy.h +++ b/google/cloud/apikeys/v2/api_keys_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,9 @@ class ApiKeysConnectionIdempotencyPolicy { virtual google::cloud::Idempotency LookupKey( google::api::apikeys::v2::LookupKeyRequest const& request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/apikeys/v2/internal/api_keys_auth_decorator.cc b/google/cloud/apikeys/v2/internal/api_keys_auth_decorator.cc index 3f5b24da5e8a7..2cee7a101ec3e 100644 --- a/google/cloud/apikeys/v2/internal/api_keys_auth_decorator.cc +++ b/google/cloud/apikeys/v2/internal/api_keys_auth_decorator.cc @@ -172,6 +172,14 @@ StatusOr ApiKeysAuth::LookupKey( return child_->LookupKey(context, options, request); } +StatusOr ApiKeysAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + future> ApiKeysAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/apikeys/v2/internal/api_keys_auth_decorator.h b/google/cloud/apikeys/v2/internal/api_keys_auth_decorator.h index c987af06e3cd0..2022492482f28 100644 --- a/google/cloud/apikeys/v2/internal/api_keys_auth_decorator.h +++ b/google/cloud/apikeys/v2/internal/api_keys_auth_decorator.h @@ -95,6 +95,10 @@ class ApiKeysAuth : public ApiKeysStub { grpc::ClientContext& context, Options const& options, google::api::apikeys::v2::LookupKeyRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/apikeys/v2/internal/api_keys_connection_impl.cc b/google/cloud/apikeys/v2/internal/api_keys_connection_impl.cc index ae42b33397ff6..495b08ab8b5f9 100644 --- a/google/cloud/apikeys/v2/internal/api_keys_connection_impl.cc +++ b/google/cloud/apikeys/v2/internal/api_keys_connection_impl.cc @@ -479,6 +479,19 @@ ApiKeysConnectionImpl::LookupKey( *current, request, __func__); } +StatusOr ApiKeysConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace apikeys_v2_internal } // namespace cloud diff --git a/google/cloud/apikeys/v2/internal/api_keys_connection_impl.h b/google/cloud/apikeys/v2/internal/api_keys_connection_impl.h index 7d9918facaa8e..0b4affed839a1 100644 --- a/google/cloud/apikeys/v2/internal/api_keys_connection_impl.h +++ b/google/cloud/apikeys/v2/internal/api_keys_connection_impl.h @@ -102,6 +102,9 @@ class ApiKeysConnectionImpl : public apikeys_v2::ApiKeysConnection { StatusOr LookupKey( google::api::apikeys::v2::LookupKeyRequest const& request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/apikeys/v2/internal/api_keys_logging_decorator.cc b/google/cloud/apikeys/v2/internal/api_keys_logging_decorator.cc index 309c49b491f9b..dc08d8cf174c3 100644 --- a/google/cloud/apikeys/v2/internal/api_keys_logging_decorator.cc +++ b/google/cloud/apikeys/v2/internal/api_keys_logging_decorator.cc @@ -193,6 +193,17 @@ StatusOr ApiKeysLogging::LookupKey( context, options, request, __func__, tracing_options_); } +StatusOr ApiKeysLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> ApiKeysLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/apikeys/v2/internal/api_keys_logging_decorator.h b/google/cloud/apikeys/v2/internal/api_keys_logging_decorator.h index b9a924af79ee7..c1e1a80148367 100644 --- a/google/cloud/apikeys/v2/internal/api_keys_logging_decorator.h +++ b/google/cloud/apikeys/v2/internal/api_keys_logging_decorator.h @@ -95,6 +95,10 @@ class ApiKeysLogging : public ApiKeysStub { grpc::ClientContext& context, Options const& options, google::api::apikeys::v2::LookupKeyRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/apikeys/v2/internal/api_keys_metadata_decorator.cc b/google/cloud/apikeys/v2/internal/api_keys_metadata_decorator.cc index 7f513db06d660..a38b3c956bce4 100644 --- a/google/cloud/apikeys/v2/internal/api_keys_metadata_decorator.cc +++ b/google/cloud/apikeys/v2/internal/api_keys_metadata_decorator.cc @@ -159,6 +159,14 @@ ApiKeysMetadata::LookupKey( return child_->LookupKey(context, options, request); } +StatusOr ApiKeysMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + future> ApiKeysMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/apikeys/v2/internal/api_keys_metadata_decorator.h b/google/cloud/apikeys/v2/internal/api_keys_metadata_decorator.h index 3aa183aed6d5f..28b73655e3f18 100644 --- a/google/cloud/apikeys/v2/internal/api_keys_metadata_decorator.h +++ b/google/cloud/apikeys/v2/internal/api_keys_metadata_decorator.h @@ -95,6 +95,10 @@ class ApiKeysMetadata : public ApiKeysStub { grpc::ClientContext& context, Options const& options, google::api::apikeys::v2::LookupKeyRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/apikeys/v2/internal/api_keys_stub.cc b/google/cloud/apikeys/v2/internal/api_keys_stub.cc index c86ed6f084ae7..78bed76fd2570 100644 --- a/google/cloud/apikeys/v2/internal/api_keys_stub.cc +++ b/google/cloud/apikeys/v2/internal/api_keys_stub.cc @@ -191,6 +191,17 @@ DefaultApiKeysStub::LookupKey( return response; } +StatusOr DefaultApiKeysStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultApiKeysStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/apikeys/v2/internal/api_keys_stub.h b/google/cloud/apikeys/v2/internal/api_keys_stub.h index d61f511c02947..41079dbaac072 100644 --- a/google/cloud/apikeys/v2/internal/api_keys_stub.h +++ b/google/cloud/apikeys/v2/internal/api_keys_stub.h @@ -94,6 +94,10 @@ class ApiKeysStub { grpc::ClientContext& context, Options const& options, google::api::apikeys::v2::LookupKeyRequest const& request) = 0; + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -112,9 +116,13 @@ class DefaultApiKeysStub : public ApiKeysStub { DefaultApiKeysStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateKey( google::cloud::CompletionQueue& cq, @@ -172,6 +180,10 @@ class DefaultApiKeysStub : public ApiKeysStub { grpc::ClientContext& context, Options const& options, google::api::apikeys::v2::LookupKeyRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -186,6 +198,8 @@ class DefaultApiKeysStub : public ApiKeysStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/apikeys/v2/internal/api_keys_stub_factory.cc b/google/cloud/apikeys/v2/internal/api_keys_stub_factory.cc index 31cededfa3759..382f11e47158d 100644 --- a/google/cloud/apikeys/v2/internal/api_keys_stub_factory.cc +++ b/google/cloud/apikeys/v2/internal/api_keys_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -43,8 +44,10 @@ std::shared_ptr CreateDefaultApiKeysStub( auto channel = auth->CreateChannel(options.get(), internal::MakeChannelArguments(options)); auto service_grpc_stub = google::api::apikeys::v2::ApiKeys::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/apikeys/v2/internal/api_keys_tracing_connection.cc b/google/cloud/apikeys/v2/internal/api_keys_tracing_connection.cc index e2e37b3ab3222..85e578504fddf 100644 --- a/google/cloud/apikeys/v2/internal/api_keys_tracing_connection.cc +++ b/google/cloud/apikeys/v2/internal/api_keys_tracing_connection.cc @@ -157,6 +157,13 @@ ApiKeysTracingConnection::LookupKey( return internal::EndSpan(*span, child_->LookupKey(request)); } +StatusOr ApiKeysTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan("apikeys_v2::ApiKeysConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeApiKeysTracingConnection( diff --git a/google/cloud/apikeys/v2/internal/api_keys_tracing_connection.h b/google/cloud/apikeys/v2/internal/api_keys_tracing_connection.h index 4413e22155a5d..7e40c48d17fc3 100644 --- a/google/cloud/apikeys/v2/internal/api_keys_tracing_connection.h +++ b/google/cloud/apikeys/v2/internal/api_keys_tracing_connection.h @@ -91,6 +91,9 @@ class ApiKeysTracingConnection : public apikeys_v2::ApiKeysConnection { StatusOr LookupKey( google::api::apikeys::v2::LookupKeyRequest const& request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/apikeys/v2/internal/api_keys_tracing_stub.cc b/google/cloud/apikeys/v2/internal/api_keys_tracing_stub.cc index fe99c042e8e91..88df642e28a5c 100644 --- a/google/cloud/apikeys/v2/internal/api_keys_tracing_stub.cc +++ b/google/cloud/apikeys/v2/internal/api_keys_tracing_stub.cc @@ -177,6 +177,17 @@ ApiKeysTracingStub::LookupKey( child_->LookupKey(context, options, request)); } +StatusOr ApiKeysTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.api.apikeys.v2.ApiKeys", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + future> ApiKeysTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/apikeys/v2/internal/api_keys_tracing_stub.h b/google/cloud/apikeys/v2/internal/api_keys_tracing_stub.h index 8c719a747d0bb..0633583786c4d 100644 --- a/google/cloud/apikeys/v2/internal/api_keys_tracing_stub.h +++ b/google/cloud/apikeys/v2/internal/api_keys_tracing_stub.h @@ -94,6 +94,10 @@ class ApiKeysTracingStub : public ApiKeysStub { grpc::ClientContext& context, Options const& options, google::api::apikeys::v2::LookupKeyRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/apikeys/v2/mocks/mock_api_keys_connection.h b/google/cloud/apikeys/v2/mocks/mock_api_keys_connection.h index e12069b7eaf93..6c35398f478c5 100644 --- a/google/cloud/apikeys/v2/mocks/mock_api_keys_connection.h +++ b/google/cloud/apikeys/v2/mocks/mock_api_keys_connection.h @@ -198,6 +198,10 @@ class MockApiKeysConnection : public apikeys_v2::ApiKeysConnection { MOCK_METHOD(StatusOr, LookupKey, (google::api::apikeys::v2::LookupKeyRequest const& request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest 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..9bb78dda3aa33 100644 --- a/google/cloud/apphub/v1/app_hub_client.cc +++ b/google/cloud/apphub/v1/app_hub_client.cc @@ -775,6 +775,92 @@ 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); +} + +StreamRange AppHubClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange AppHubClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr AppHubClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr AppHubClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status AppHubClient::DeleteOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status AppHubClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status AppHubClient::CancelOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status AppHubClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..304fd59dfa326 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,458 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..60881d3776c41 100644 --- a/google/cloud/apphub/v1/app_hub_connection.cc +++ b/google/cloud/apphub/v1/app_hub_connection.cc @@ -380,6 +380,56 @@ 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"); +} + +StreamRange AppHubConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr AppHubConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AppHubConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AppHubConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeAppHubConnection(Options options) { internal::CheckExpectedOptions> 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..b387ec2a43b18 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,52 @@ 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; +} + +Idempotency AppHubConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AppHubConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AppHubConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AppHubConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..3d336bb2f2b3d 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,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -122,6 +125,33 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..f89ae3524161a 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,81 @@ 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); +} + +StatusOr +AppHubAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr AppHubAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status AppHubAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status AppHubAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..92f90eb7169b3 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..722f7122679ba 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,165 @@ 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__); +} + +StreamRange +AppHubConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr AppHubConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status AppHubConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status AppHubConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..b8d2914b1835f 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..4e061a1aede07 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,108 @@ 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_); +} + +StatusOr +AppHubLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AppHubLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AppHubLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AppHubLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..b5d2debd42155 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..f397482b69e0f 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,84 @@ 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); +} + +StatusOr +AppHubMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr AppHubMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status AppHubMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status AppHubMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..38c91580bd843 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..3d7b988b6ffb9 100644 --- a/google/cloud/apphub/v1/internal/app_hub_stub.cc +++ b/google/cloud/apphub/v1/internal/app_hub_stub.cc @@ -564,6 +564,109 @@ 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; +} + +StatusOr +DefaultAppHubStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAppHubStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultAppHubStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultAppHubStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..cf1018f36dd6f 100644 --- a/google/cloud/apphub/v1/internal/app_hub_stub.h +++ b/google/cloud/apphub/v1/internal/app_hub_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -249,6 +251,44 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -267,9 +307,18 @@ class DefaultAppHubStub : public AppHubStub { DefaultAppHubStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr LookupServiceProjectAttachment( @@ -476,6 +525,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -490,6 +575,11 @@ class DefaultAppHubStub : public AppHubStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..b7bd13c4a9754 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,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -43,8 +46,14 @@ 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_operations_stub = + google::longrunning::Operations::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_operations_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..e2e0c310b8dbe 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,80 @@ 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)); +} + +StreamRange +AppHubTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan("apphub_v1::AppHubConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr AppHubTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan("apphub_v1::AppHubConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status AppHubTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = + internal::MakeSpan("apphub_v1::AppHubConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status AppHubTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("apphub_v1::AppHubConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..151167469297c 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..34b45ce686409 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,108 @@ 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)); +} + +StatusOr +AppHubTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.apphub.v1.AppHub", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr AppHubTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.apphub.v1.AppHub", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status AppHubTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.apphub.v1.AppHub", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status AppHubTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.apphub.v1.AppHub", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..76147543c3b67 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..2aeaaff8eb4a4 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,42 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..7a1fd35efd66a 100644 --- a/google/cloud/artifactregistry/v1/artifact_registry_client.cc +++ b/google/cloud/artifactregistry/v1/artifact_registry_client.cc @@ -781,6 +781,33 @@ 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); +} + +StatusOr ArtifactRegistryClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr ArtifactRegistryClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(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..6d333d2616a0a 100644 --- a/google/cloud/artifactregistry/v1/artifact_registry_client.h +++ b/google/cloud/artifactregistry/v1/artifact_registry_client.h @@ -2606,6 +2606,136 @@ 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 = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest 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..f50dbc040b7b6 100644 --- a/google/cloud/artifactregistry/v1/artifact_registry_connection.cc +++ b/google/cloud/artifactregistry/v1/artifact_registry_connection.cc @@ -402,6 +402,26 @@ 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"); +} + +StatusOr +ArtifactRegistryConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeArtifactRegistryConnection( Options options) { internal::CheckExpectedOptions ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest 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..6302b45b4a4ec 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,21 @@ 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; +} + +Idempotency ArtifactRegistryConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest 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..d47f89bf37348 100644 --- a/google/cloud/artifactregistry/v1/artifact_registry_connection_idempotency_policy.h +++ b/google/cloud/artifactregistry/v1/artifact_registry_connection_idempotency_policy.h @@ -21,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -163,6 +165,15 @@ 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); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest 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..8352f682f4d8f 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,31 @@ 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); +} + +StatusOr ArtifactRegistryAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(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..efe646f5e1ed2 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,18 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..fb84d8c638627 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,69 @@ 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__); +} + +StatusOr +ArtifactRegistryConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(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..f1cddb6267583 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,15 @@ 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; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest 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..f8555a8c7f2bc 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,41 @@ 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_); +} + +StatusOr ArtifactRegistryLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(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..cc7610698bb01 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,18 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..62fa8d14119a1 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,32 @@ 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); +} + +StatusOr ArtifactRegistryMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(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..6814f0ab98068 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,18 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..2dc566ed39979 100644 --- a/google/cloud/artifactregistry/v1/internal/artifact_registry_stub.cc +++ b/google/cloud/artifactregistry/v1/internal/artifact_registry_stub.cc @@ -626,6 +626,42 @@ 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; +} + +StatusOr +DefaultArtifactRegistryStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&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..9920a5d7a4676 100644 --- a/google/cloud/artifactregistry/v1/internal/artifact_registry_stub.h +++ b/google/cloud/artifactregistry/v1/internal/artifact_registry_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 @@ -290,6 +291,19 @@ 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 StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -309,9 +323,16 @@ class DefaultArtifactRegistryStub : public ArtifactRegistryStub { std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListDockerImages( @@ -551,6 +572,18 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -567,6 +600,10 @@ class DefaultArtifactRegistryStub : public ArtifactRegistryStub { std::unique_ptr< google::devtools::artifactregistry::v1::ArtifactRegistry::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..95a7a5d37c6ad 100644 --- a/google/cloud/artifactregistry/v1/internal/artifact_registry_stub_factory.cc +++ b/google/cloud/artifactregistry/v1/internal/artifact_registry_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,14 @@ std::shared_ptr CreateDefaultArtifactRegistryStub( auto service_grpc_stub = google::devtools::artifactregistry::v1::ArtifactRegistry::NewStub( channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..c8b2cea93b631 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,35 @@ 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)); +} + +StatusOr +ArtifactRegistryTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "artifactregistry_v1::ArtifactRegistryConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(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..9e62c79b4a2c3 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,15 @@ 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; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest 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..69b3fe4610a55 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,42 @@ 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)); +} + +StatusOr +ArtifactRegistryTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.devtools.artifactregistry.v1.ArtifactRegistry", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(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..ae535e0a4ff5f 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,18 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..9169bac6a3fc0 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,18 @@ 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)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/asset/v1/asset_client.cc b/google/cloud/asset/v1/asset_client.cc index 7d8c3eda75fbf..fe4e972663bb7 100644 --- a/google/cloud/asset/v1/asset_client.cc +++ b/google/cloud/asset/v1/asset_client.cc @@ -391,6 +391,20 @@ AssetServiceClient::AnalyzeOrgPolicyGovernedAssets( return connection_->AnalyzeOrgPolicyGovernedAssets(std::move(request)); } +StatusOr AssetServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr AssetServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace asset_v1 } // namespace cloud diff --git a/google/cloud/asset/v1/asset_client.h b/google/cloud/asset/v1/asset_client.h index 9ffc2e873c6ae..a39c4c2276186 100644 --- a/google/cloud/asset/v1/asset_client.h +++ b/google/cloud/asset/v1/asset_client.h @@ -1730,6 +1730,66 @@ class AssetServiceClient { google::cloud::asset::v1::AnalyzeOrgPolicyGovernedAssetsRequest request, Options opts = {}); + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/asset/v1/asset_connection.cc b/google/cloud/asset/v1/asset_connection.cc index 0b59a55bd7849..d70e1dac37ca5 100644 --- a/google/cloud/asset/v1/asset_connection.cc +++ b/google/cloud/asset/v1/asset_connection.cc @@ -222,6 +222,11 @@ AssetServiceConnection::AnalyzeOrgPolicyGovernedAssets( AnalyzeOrgPolicyGovernedAssetsResponse::GovernedAsset>>(); } +StatusOr AssetServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeAssetServiceConnection( Options options) { internal::CheckExpectedOptions AnalyzeOrgPolicyGovernedAssets( google::cloud::asset::v1::AnalyzeOrgPolicyGovernedAssetsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/asset/v1/asset_connection_idempotency_policy.cc b/google/cloud/asset/v1/asset_connection_idempotency_policy.cc index 9c304ddeca7d2..45506cf8b96d6 100644 --- a/google/cloud/asset/v1/asset_connection_idempotency_policy.cc +++ b/google/cloud/asset/v1/asset_connection_idempotency_policy.cc @@ -155,6 +155,11 @@ AssetServiceConnectionIdempotencyPolicy::AnalyzeOrgPolicyGovernedAssets( return Idempotency::kIdempotent; } +Idempotency AssetServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultAssetServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/asset/v1/asset_connection_idempotency_policy.h b/google/cloud/asset/v1/asset_connection_idempotency_policy.h index a660981766ee6..9bbf0da4f4d49 100644 --- a/google/cloud/asset/v1/asset_connection_idempotency_policy.h +++ b/google/cloud/asset/v1/asset_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,9 @@ class AssetServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency AnalyzeOrgPolicyGovernedAssets( google::cloud::asset::v1::AnalyzeOrgPolicyGovernedAssetsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/asset/v1/internal/asset_auth_decorator.cc b/google/cloud/asset/v1/internal/asset_auth_decorator.cc index ddecab03294ae..4bd1e5e57da91 100644 --- a/google/cloud/asset/v1/internal/asset_auth_decorator.cc +++ b/google/cloud/asset/v1/internal/asset_auth_decorator.cc @@ -276,6 +276,14 @@ AssetServiceAuth::AnalyzeOrgPolicyGovernedAssets( return child_->AnalyzeOrgPolicyGovernedAssets(context, options, request); } +StatusOr AssetServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + future> AssetServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/asset/v1/internal/asset_auth_decorator.h b/google/cloud/asset/v1/internal/asset_auth_decorator.h index d302c2331b70f..2a6420080f586 100644 --- a/google/cloud/asset/v1/internal/asset_auth_decorator.h +++ b/google/cloud/asset/v1/internal/asset_auth_decorator.h @@ -163,6 +163,10 @@ class AssetServiceAuth : public AssetServiceStub { google::cloud::asset::v1::AnalyzeOrgPolicyGovernedAssetsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/asset/v1/internal/asset_connection_impl.cc b/google/cloud/asset/v1/internal/asset_connection_impl.cc index b504351391aa6..1cf747190c448 100644 --- a/google/cloud/asset/v1/internal/asset_connection_impl.cc +++ b/google/cloud/asset/v1/internal/asset_connection_impl.cc @@ -698,6 +698,20 @@ AssetServiceConnectionImpl::AnalyzeOrgPolicyGovernedAssets( }); } +StatusOr +AssetServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace asset_v1_internal } // namespace cloud diff --git a/google/cloud/asset/v1/internal/asset_connection_impl.h b/google/cloud/asset/v1/internal/asset_connection_impl.h index 88acc3ae4b7a5..952f6e78b9270 100644 --- a/google/cloud/asset/v1/internal/asset_connection_impl.h +++ b/google/cloud/asset/v1/internal/asset_connection_impl.h @@ -158,6 +158,9 @@ class AssetServiceConnectionImpl : public asset_v1::AssetServiceConnection { google::cloud::asset::v1::AnalyzeOrgPolicyGovernedAssetsRequest request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/asset/v1/internal/asset_logging_decorator.cc b/google/cloud/asset/v1/internal/asset_logging_decorator.cc index e9c9938e27cba..a4aca53587acf 100644 --- a/google/cloud/asset/v1/internal/asset_logging_decorator.cc +++ b/google/cloud/asset/v1/internal/asset_logging_decorator.cc @@ -359,6 +359,17 @@ AssetServiceLogging::AnalyzeOrgPolicyGovernedAssets( context, options, request, __func__, tracing_options_); } +StatusOr AssetServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> AssetServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/asset/v1/internal/asset_logging_decorator.h b/google/cloud/asset/v1/internal/asset_logging_decorator.h index bd4609a05079b..f84bd68791412 100644 --- a/google/cloud/asset/v1/internal/asset_logging_decorator.h +++ b/google/cloud/asset/v1/internal/asset_logging_decorator.h @@ -163,6 +163,10 @@ class AssetServiceLogging : public AssetServiceStub { google::cloud::asset::v1::AnalyzeOrgPolicyGovernedAssetsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/asset/v1/internal/asset_metadata_decorator.cc b/google/cloud/asset/v1/internal/asset_metadata_decorator.cc index 40ea52d86ddac..90503e18cbeef 100644 --- a/google/cloud/asset/v1/internal/asset_metadata_decorator.cc +++ b/google/cloud/asset/v1/internal/asset_metadata_decorator.cc @@ -283,6 +283,14 @@ AssetServiceMetadata::AnalyzeOrgPolicyGovernedAssets( return child_->AnalyzeOrgPolicyGovernedAssets(context, options, request); } +StatusOr AssetServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + future> AssetServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/asset/v1/internal/asset_metadata_decorator.h b/google/cloud/asset/v1/internal/asset_metadata_decorator.h index e3f7b63ef68de..0ca1f7b156daa 100644 --- a/google/cloud/asset/v1/internal/asset_metadata_decorator.h +++ b/google/cloud/asset/v1/internal/asset_metadata_decorator.h @@ -163,6 +163,10 @@ class AssetServiceMetadata : public AssetServiceStub { google::cloud::asset::v1::AnalyzeOrgPolicyGovernedAssetsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/asset/v1/internal/asset_stub.cc b/google/cloud/asset/v1/internal/asset_stub.cc index 9cf439edc9946..72cc282d6b2c0 100644 --- a/google/cloud/asset/v1/internal/asset_stub.cc +++ b/google/cloud/asset/v1/internal/asset_stub.cc @@ -348,6 +348,17 @@ DefaultAssetServiceStub::AnalyzeOrgPolicyGovernedAssets( return response; } +StatusOr DefaultAssetServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultAssetServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/asset/v1/internal/asset_stub.h b/google/cloud/asset/v1/internal/asset_stub.h index 7759e5fa83358..21a3fb42adb91 100644 --- a/google/cloud/asset/v1/internal/asset_stub.h +++ b/google/cloud/asset/v1/internal/asset_stub.h @@ -161,6 +161,10 @@ class AssetServiceStub { google::cloud::asset::v1::AnalyzeOrgPolicyGovernedAssetsRequest const& request) = 0; + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -179,9 +183,13 @@ class DefaultAssetServiceStub : public AssetServiceStub { DefaultAssetServiceStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} future> AsyncExportAssets( google::cloud::CompletionQueue& cq, @@ -307,6 +315,10 @@ class DefaultAssetServiceStub : public AssetServiceStub { google::cloud::asset::v1::AnalyzeOrgPolicyGovernedAssetsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -322,6 +334,8 @@ class DefaultAssetServiceStub : public AssetServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/asset/v1/internal/asset_stub_factory.cc b/google/cloud/asset/v1/internal/asset_stub_factory.cc index a6e5e9f1ecb3e..44b9a54f41392 100644 --- a/google/cloud/asset/v1/internal/asset_stub_factory.cc +++ b/google/cloud/asset/v1/internal/asset_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 CreateDefaultAssetServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::asset::v1::AssetService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/asset/v1/internal/asset_tracing_connection.cc b/google/cloud/asset/v1/internal/asset_tracing_connection.cc index bf773c9e2df87..845b455cc0064 100644 --- a/google/cloud/asset/v1/internal/asset_tracing_connection.cc +++ b/google/cloud/asset/v1/internal/asset_tracing_connection.cc @@ -302,6 +302,15 @@ AssetServiceTracingConnection::AnalyzeOrgPolicyGovernedAssets( GovernedAsset>(std::move(span), std::move(sr)); } +StatusOr +AssetServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("asset_v1::AssetServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/asset/v1/internal/asset_tracing_connection.h b/google/cloud/asset/v1/internal/asset_tracing_connection.h index 172de4d84b08a..9c530c2cf0598 100644 --- a/google/cloud/asset/v1/internal/asset_tracing_connection.h +++ b/google/cloud/asset/v1/internal/asset_tracing_connection.h @@ -146,6 +146,9 @@ class AssetServiceTracingConnection : public asset_v1::AssetServiceConnection { google::cloud::asset::v1::AnalyzeOrgPolicyGovernedAssetsRequest request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/asset/v1/internal/asset_tracing_stub.cc b/google/cloud/asset/v1/internal/asset_tracing_stub.cc index fe4429430145b..1eacf06144070 100644 --- a/google/cloud/asset/v1/internal/asset_tracing_stub.cc +++ b/google/cloud/asset/v1/internal/asset_tracing_stub.cc @@ -340,6 +340,17 @@ AssetServiceTracingStub::AnalyzeOrgPolicyGovernedAssets( child_->AnalyzeOrgPolicyGovernedAssets(context, options, request)); } +StatusOr AssetServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.asset.v1.AssetService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + future> AssetServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/asset/v1/internal/asset_tracing_stub.h b/google/cloud/asset/v1/internal/asset_tracing_stub.h index 577849582cc9d..8c7a9e4e93cac 100644 --- a/google/cloud/asset/v1/internal/asset_tracing_stub.h +++ b/google/cloud/asset/v1/internal/asset_tracing_stub.h @@ -162,6 +162,10 @@ class AssetServiceTracingStub : public AssetServiceStub { google::cloud::asset::v1::AnalyzeOrgPolicyGovernedAssetsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/asset/v1/mocks/mock_asset_connection.h b/google/cloud/asset/v1/mocks/mock_asset_connection.h index 3fb729e731338..38c30882058d6 100644 --- a/google/cloud/asset/v1/mocks/mock_asset_connection.h +++ b/google/cloud/asset/v1/mocks/mock_asset_connection.h @@ -236,6 +236,10 @@ class MockAssetServiceConnection : public asset_v1::AssetServiceConnection { AnalyzeOrgPolicyGovernedAssets, (google::cloud::asset::v1::AnalyzeOrgPolicyGovernedAssetsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/assuredworkloads/v1/assured_workloads_client.cc b/google/cloud/assuredworkloads/v1/assured_workloads_client.cc index 07f23c6d430bb..7b762eada4feb 100644 --- a/google/cloud/assuredworkloads/v1/assured_workloads_client.cc +++ b/google/cloud/assuredworkloads/v1/assured_workloads_client.cc @@ -200,6 +200,40 @@ AssuredWorkloadsServiceClient::AcknowledgeViolation( return connection_->AcknowledgeViolation(request); } +StreamRange +AssuredWorkloadsServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +AssuredWorkloadsServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +AssuredWorkloadsServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +AssuredWorkloadsServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace assuredworkloads_v1 } // namespace cloud diff --git a/google/cloud/assuredworkloads/v1/assured_workloads_client.h b/google/cloud/assuredworkloads/v1/assured_workloads_client.h index 3efaf118dbef0..940a31ca48e90 100644 --- a/google/cloud/assuredworkloads/v1/assured_workloads_client.h +++ b/google/cloud/assuredworkloads/v1/assured_workloads_client.h @@ -683,6 +683,158 @@ class AssuredWorkloadsServiceClient { request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/assuredworkloads/v1/assured_workloads_connection.cc b/google/cloud/assuredworkloads/v1/assured_workloads_connection.cc index 00248597a7302..225b5fde79392 100644 --- a/google/cloud/assuredworkloads/v1/assured_workloads_connection.cc +++ b/google/cloud/assuredworkloads/v1/assured_workloads_connection.cc @@ -115,6 +115,20 @@ AssuredWorkloadsServiceConnection::AcknowledgeViolation( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +AssuredWorkloadsServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +AssuredWorkloadsServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeAssuredWorkloadsServiceConnection(Options options) { internal::CheckExpectedOptions ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/assuredworkloads/v1/assured_workloads_connection_idempotency_policy.cc b/google/cloud/assuredworkloads/v1/assured_workloads_connection_idempotency_policy.cc index 8ce997aea50f1..d6b00fb3002db 100644 --- a/google/cloud/assuredworkloads/v1/assured_workloads_connection_idempotency_policy.cc +++ b/google/cloud/assuredworkloads/v1/assured_workloads_connection_idempotency_policy.cc @@ -83,6 +83,16 @@ AssuredWorkloadsServiceConnectionIdempotencyPolicy::AcknowledgeViolation( return Idempotency::kNonIdempotent; } +Idempotency AssuredWorkloadsServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AssuredWorkloadsServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultAssuredWorkloadsServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/assuredworkloads/v1/assured_workloads_connection_idempotency_policy.h b/google/cloud/assuredworkloads/v1/assured_workloads_connection_idempotency_policy.h index a79a12f5eaa7f..291a560655c7e 100644 --- a/google/cloud/assuredworkloads/v1/assured_workloads_connection_idempotency_policy.h +++ b/google/cloud/assuredworkloads/v1/assured_workloads_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -68,6 +69,12 @@ class AssuredWorkloadsServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency AcknowledgeViolation( google::cloud::assuredworkloads::v1::AcknowledgeViolationRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/assuredworkloads/v1/internal/assured_workloads_auth_decorator.cc b/google/cloud/assuredworkloads/v1/internal/assured_workloads_auth_decorator.cc index dbceddb6bf20d..643f48be0ecee 100644 --- a/google/cloud/assuredworkloads/v1/internal/assured_workloads_auth_decorator.cc +++ b/google/cloud/assuredworkloads/v1/internal/assured_workloads_auth_decorator.cc @@ -133,6 +133,24 @@ AssuredWorkloadsServiceAuth::AcknowledgeViolation( return child_->AcknowledgeViolation(context, options, request); } +StatusOr +AssuredWorkloadsServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +AssuredWorkloadsServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + future> AssuredWorkloadsServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/assuredworkloads/v1/internal/assured_workloads_auth_decorator.h b/google/cloud/assuredworkloads/v1/internal/assured_workloads_auth_decorator.h index 14b5061a59b21..b45484afd1d98 100644 --- a/google/cloud/assuredworkloads/v1/internal/assured_workloads_auth_decorator.h +++ b/google/cloud/assuredworkloads/v1/internal/assured_workloads_auth_decorator.h @@ -95,6 +95,14 @@ class AssuredWorkloadsServiceAuth : public AssuredWorkloadsServiceStub { google::cloud::assuredworkloads::v1::AcknowledgeViolationRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/assuredworkloads/v1/internal/assured_workloads_connection_impl.cc b/google/cloud/assuredworkloads/v1/internal/assured_workloads_connection_impl.cc index 0a62ba830431c..e7e61f0fb5c5d 100644 --- a/google/cloud/assuredworkloads/v1/internal/assured_workloads_connection_impl.cc +++ b/google/cloud/assuredworkloads/v1/internal/assured_workloads_connection_impl.cc @@ -329,6 +329,54 @@ AssuredWorkloadsServiceConnectionImpl::AcknowledgeViolation( *current, request, __func__); } +StreamRange +AssuredWorkloadsServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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< + assuredworkloads_v1::AssuredWorkloadsServiceRetryPolicy>( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +AssuredWorkloadsServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace assuredworkloads_v1_internal } // namespace cloud diff --git a/google/cloud/assuredworkloads/v1/internal/assured_workloads_connection_impl.h b/google/cloud/assuredworkloads/v1/internal/assured_workloads_connection_impl.h index 62c73d7d37b49..bf8d205a3df82 100644 --- a/google/cloud/assuredworkloads/v1/internal/assured_workloads_connection_impl.h +++ b/google/cloud/assuredworkloads/v1/internal/assured_workloads_connection_impl.h @@ -101,6 +101,12 @@ class AssuredWorkloadsServiceConnectionImpl google::cloud::assuredworkloads::v1::AcknowledgeViolationRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr diff --git a/google/cloud/assuredworkloads/v1/internal/assured_workloads_logging_decorator.cc b/google/cloud/assuredworkloads/v1/internal/assured_workloads_logging_decorator.cc index 41c615158c930..139602cf7027d 100644 --- a/google/cloud/assuredworkloads/v1/internal/assured_workloads_logging_decorator.cc +++ b/google/cloud/assuredworkloads/v1/internal/assured_workloads_logging_decorator.cc @@ -172,6 +172,30 @@ AssuredWorkloadsServiceLogging::AcknowledgeViolation( context, options, request, __func__, tracing_options_); } +StatusOr +AssuredWorkloadsServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AssuredWorkloadsServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> AssuredWorkloadsServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/assuredworkloads/v1/internal/assured_workloads_logging_decorator.h b/google/cloud/assuredworkloads/v1/internal/assured_workloads_logging_decorator.h index 2b31ebea32139..300fde6d1702c 100644 --- a/google/cloud/assuredworkloads/v1/internal/assured_workloads_logging_decorator.h +++ b/google/cloud/assuredworkloads/v1/internal/assured_workloads_logging_decorator.h @@ -95,6 +95,14 @@ class AssuredWorkloadsServiceLogging : public AssuredWorkloadsServiceStub { google::cloud::assuredworkloads::v1::AcknowledgeViolationRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/assuredworkloads/v1/internal/assured_workloads_metadata_decorator.cc b/google/cloud/assuredworkloads/v1/internal/assured_workloads_metadata_decorator.cc index b145269d9097d..1312347835a8e 100644 --- a/google/cloud/assuredworkloads/v1/internal/assured_workloads_metadata_decorator.cc +++ b/google/cloud/assuredworkloads/v1/internal/assured_workloads_metadata_decorator.cc @@ -136,6 +136,24 @@ AssuredWorkloadsServiceMetadata::AcknowledgeViolation( return child_->AcknowledgeViolation(context, options, request); } +StatusOr +AssuredWorkloadsServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +AssuredWorkloadsServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + future> AssuredWorkloadsServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/assuredworkloads/v1/internal/assured_workloads_metadata_decorator.h b/google/cloud/assuredworkloads/v1/internal/assured_workloads_metadata_decorator.h index 44a95bc5df0e7..d849d8f8cfbb9 100644 --- a/google/cloud/assuredworkloads/v1/internal/assured_workloads_metadata_decorator.h +++ b/google/cloud/assuredworkloads/v1/internal/assured_workloads_metadata_decorator.h @@ -96,6 +96,14 @@ class AssuredWorkloadsServiceMetadata : public AssuredWorkloadsServiceStub { google::cloud::assuredworkloads::v1::AcknowledgeViolationRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/assuredworkloads/v1/internal/assured_workloads_stub.cc b/google/cloud/assuredworkloads/v1/internal/assured_workloads_stub.cc index 4324ac3a2ae82..f59dbf9f4d182 100644 --- a/google/cloud/assuredworkloads/v1/internal/assured_workloads_stub.cc +++ b/google/cloud/assuredworkloads/v1/internal/assured_workloads_stub.cc @@ -161,6 +161,30 @@ DefaultAssuredWorkloadsServiceStub::AcknowledgeViolation( return response; } +StatusOr +DefaultAssuredWorkloadsServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAssuredWorkloadsServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultAssuredWorkloadsServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/assuredworkloads/v1/internal/assured_workloads_stub.h b/google/cloud/assuredworkloads/v1/internal/assured_workloads_stub.h index d668c133ffb94..b77406127aae4 100644 --- a/google/cloud/assuredworkloads/v1/internal/assured_workloads_stub.h +++ b/google/cloud/assuredworkloads/v1/internal/assured_workloads_stub.h @@ -96,6 +96,14 @@ class AssuredWorkloadsServiceStub { google::cloud::assuredworkloads::v1::AcknowledgeViolationRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -115,9 +123,13 @@ class DefaultAssuredWorkloadsServiceStub : public AssuredWorkloadsServiceStub { std::unique_ptr grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateWorkload( google::cloud::CompletionQueue& cq, @@ -175,6 +187,14 @@ class DefaultAssuredWorkloadsServiceStub : public AssuredWorkloadsServiceStub { google::cloud::assuredworkloads::v1::AcknowledgeViolationRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -191,6 +211,8 @@ class DefaultAssuredWorkloadsServiceStub : public AssuredWorkloadsServiceStub { std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/assuredworkloads/v1/internal/assured_workloads_stub_factory.cc b/google/cloud/assuredworkloads/v1/internal/assured_workloads_stub_factory.cc index 20c09925d3ef6..48d3f1857b7e8 100644 --- a/google/cloud/assuredworkloads/v1/internal/assured_workloads_stub_factory.cc +++ b/google/cloud/assuredworkloads/v1/internal/assured_workloads_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 @@ CreateDefaultAssuredWorkloadsServiceStub( auto service_grpc_stub = google::cloud::assuredworkloads::v1::AssuredWorkloadsService::NewStub( channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/assuredworkloads/v1/internal/assured_workloads_tracing_connection.cc b/google/cloud/assuredworkloads/v1/internal/assured_workloads_tracing_connection.cc index 3ca408f99de82..c761ea543cb04 100644 --- a/google/cloud/assuredworkloads/v1/internal/assured_workloads_tracing_connection.cc +++ b/google/cloud/assuredworkloads/v1/internal/assured_workloads_tracing_connection.cc @@ -145,6 +145,26 @@ AssuredWorkloadsServiceTracingConnection::AcknowledgeViolation( return internal::EndSpan(*span, child_->AcknowledgeViolation(request)); } +StreamRange +AssuredWorkloadsServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "assuredworkloads_v1::AssuredWorkloadsServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AssuredWorkloadsServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "assuredworkloads_v1::AssuredWorkloadsServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/assuredworkloads/v1/internal/assured_workloads_tracing_connection.h b/google/cloud/assuredworkloads/v1/internal/assured_workloads_tracing_connection.h index 157cbacde4d5d..be933bd9dce06 100644 --- a/google/cloud/assuredworkloads/v1/internal/assured_workloads_tracing_connection.h +++ b/google/cloud/assuredworkloads/v1/internal/assured_workloads_tracing_connection.h @@ -89,6 +89,12 @@ class AssuredWorkloadsServiceTracingConnection google::cloud::assuredworkloads::v1::AcknowledgeViolationRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; diff --git a/google/cloud/assuredworkloads/v1/internal/assured_workloads_tracing_stub.cc b/google/cloud/assuredworkloads/v1/internal/assured_workloads_tracing_stub.cc index 516e6d5172d7d..f61ace61860f9 100644 --- a/google/cloud/assuredworkloads/v1/internal/assured_workloads_tracing_stub.cc +++ b/google/cloud/assuredworkloads/v1/internal/assured_workloads_tracing_stub.cc @@ -167,6 +167,32 @@ AssuredWorkloadsServiceTracingStub::AcknowledgeViolation( context, *span, child_->AcknowledgeViolation(context, options, request)); } +StatusOr +AssuredWorkloadsServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.assuredworkloads.v1.AssuredWorkloadsService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +AssuredWorkloadsServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.assuredworkloads.v1.AssuredWorkloadsService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + future> AssuredWorkloadsServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/assuredworkloads/v1/internal/assured_workloads_tracing_stub.h b/google/cloud/assuredworkloads/v1/internal/assured_workloads_tracing_stub.h index 2a233d4303dfc..2a7e2fb2ad12e 100644 --- a/google/cloud/assuredworkloads/v1/internal/assured_workloads_tracing_stub.h +++ b/google/cloud/assuredworkloads/v1/internal/assured_workloads_tracing_stub.h @@ -95,6 +95,14 @@ class AssuredWorkloadsServiceTracingStub : public AssuredWorkloadsServiceStub { google::cloud::assuredworkloads::v1::AcknowledgeViolationRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/assuredworkloads/v1/mocks/mock_assured_workloads_connection.h b/google/cloud/assuredworkloads/v1/mocks/mock_assured_workloads_connection.h index e2934bc06161f..ded9aa4e4a31e 100644 --- a/google/cloud/assuredworkloads/v1/mocks/mock_assured_workloads_connection.h +++ b/google/cloud/assuredworkloads/v1/mocks/mock_assured_workloads_connection.h @@ -133,6 +133,13 @@ class MockAssuredWorkloadsServiceConnection (google::cloud::assuredworkloads::v1::AcknowledgeViolationRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest 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..ae0630faeaf1f 100644 --- a/google/cloud/backupdr/v1/backup_dr_client.cc +++ b/google/cloud/backupdr/v1/backup_dr_client.cc @@ -151,6 +151,92 @@ 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); +} + +StreamRange BackupDRClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange BackupDRClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr BackupDRClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr BackupDRClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status BackupDRClient::DeleteOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status BackupDRClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status BackupDRClient::CancelOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status BackupDRClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..b306c9990cf89 100644 --- a/google/cloud/backupdr/v1/backup_dr_client.h +++ b/google/cloud/backupdr/v1/backup_dr_client.h @@ -461,6 +461,458 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..db62c730d4175 100644 --- a/google/cloud/backupdr/v1/backup_dr_connection.cc +++ b/google/cloud/backupdr/v1/backup_dr_connection.cc @@ -100,6 +100,57 @@ 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"); +} + +StreamRange BackupDRConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr BackupDRConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status BackupDRConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status BackupDRConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeBackupDRConnection(Options options) { internal::CheckExpectedOptions> 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..2832e26531fe8 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,52 @@ 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; +} + +Idempotency BackupDRConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency BackupDRConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency BackupDRConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency BackupDRConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..a4b964a9afce0 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,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -49,6 +52,33 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..10724781b138d 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,81 @@ 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); +} + +StatusOr +BackupDRAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr BackupDRAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status BackupDRAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status BackupDRAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..caa13146d3f56 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..a9cafd9781b4f 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,165 @@ 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__); +} + +StreamRange +BackupDRConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr BackupDRConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status BackupDRConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status BackupDRConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..2cb9fc5a5b2ab 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..4c8b6db827711 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,108 @@ 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_); +} + +StatusOr +BackupDRLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr BackupDRLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status BackupDRLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status BackupDRLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..50d26466209e1 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..9740308b1149c 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,84 @@ 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); +} + +StatusOr +BackupDRMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr BackupDRMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status BackupDRMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status BackupDRMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..077550de99108 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..b6bb66a34807a 100644 --- a/google/cloud/backupdr/v1/internal/backup_dr_stub.cc +++ b/google/cloud/backupdr/v1/internal/backup_dr_stub.cc @@ -119,6 +119,109 @@ 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; +} + +StatusOr +DefaultBackupDRStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultBackupDRStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultBackupDRStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultBackupDRStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..ae0b455d55f82 100644 --- a/google/cloud/backupdr/v1/internal/backup_dr_stub.h +++ b/google/cloud/backupdr/v1/internal/backup_dr_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -76,6 +78,44 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -94,9 +134,18 @@ class DefaultBackupDRStub : public BackupDRStub { DefaultBackupDRStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListManagementServers( @@ -133,6 +182,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -148,6 +233,11 @@ class DefaultBackupDRStub : public BackupDRStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..9fce672bb3fd2 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,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,8 +47,14 @@ std::shared_ptr CreateDefaultBackupDRStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::backupdr::v1::BackupDR::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..b729525e4e905 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,87 @@ 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)); +} + +StreamRange +BackupDRTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("backupdr_v1::BackupDRConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +BackupDRTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("backupdr_v1::BackupDRConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status BackupDRTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = + internal::MakeSpan("backupdr_v1::BackupDRConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status BackupDRTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("backupdr_v1::BackupDRConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..9ece22c6dee16 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..5b9a4956476d8 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,108 @@ 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)); +} + +StatusOr +BackupDRTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.backupdr.v1.BackupDR", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr BackupDRTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.backupdr.v1.BackupDR", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status BackupDRTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.backupdr.v1.BackupDR", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status BackupDRTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.backupdr.v1.BackupDR", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..57598506375f9 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..e80fac75b1600 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,42 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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 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..b4231a3fb5023 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,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -389,6 +390,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 +418,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 +772,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 +796,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..c571e44b9f091 100644 --- a/google/cloud/batch/v1/batch_client.cc +++ b/google/cloud/batch/v1/batch_client.cc @@ -142,6 +142,76 @@ 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); +} + +StreamRange BatchServiceClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange BatchServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr BatchServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr BatchServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status BatchServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status BatchServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status BatchServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status BatchServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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 bd940a24ad23e..e05b45cbacc55 100644 --- a/google/cloud/batch/v1/batch_client.h +++ b/google/cloud/batch/v1/batch_client.h @@ -530,6 +530,356 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..f4a3c502ae441 100644 --- a/google/cloud/batch/v1/batch_connection.cc +++ b/google/cloud/batch/v1/batch_connection.cc @@ -88,6 +88,42 @@ 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"); +} + +StreamRange +BatchServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr BatchServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status BatchServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status BatchServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeBatchServiceConnection( Options options) { internal::CheckExpectedOptions ListTasks( google::cloud::batch::v1::ListTasksRequest request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..4abad76e89a77 100644 --- a/google/cloud/batch/v1/batch_connection_idempotency_policy.cc +++ b/google/cloud/batch/v1/batch_connection_idempotency_policy.cc @@ -64,6 +64,36 @@ 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; +} + +Idempotency BatchServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency BatchServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency BatchServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency BatchServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..38ac4b4237526 100644 --- a/google/cloud/batch/v1/batch_connection_idempotency_policy.h +++ b/google/cloud/batch/v1/batch_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,24 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..38135372c6026 100644 --- a/google/cloud/batch/v1/internal/batch_auth_decorator.cc +++ b/google/cloud/batch/v1/internal/batch_auth_decorator.cc @@ -100,6 +100,56 @@ 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); +} + +StatusOr +BatchServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr BatchServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status BatchServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status BatchServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..3f89075c4aad3 100644 --- a/google/cloud/batch/v1/internal/batch_auth_decorator.h +++ b/google/cloud/batch/v1/internal/batch_auth_decorator.h @@ -69,6 +69,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..7029a0e5fb3c3 100644 --- a/google/cloud/batch/v1/internal/batch_connection_impl.cc +++ b/google/cloud/batch/v1/internal/batch_connection_impl.cc @@ -252,6 +252,127 @@ 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__); +} + +StreamRange +BatchServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +BatchServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status BatchServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status BatchServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..38a988f0a5fa1 100644 --- a/google/cloud/batch/v1/internal/batch_connection_impl.h +++ b/google/cloud/batch/v1/internal/batch_connection_impl.h @@ -76,6 +76,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..ba214cc41c1c1 100644 --- a/google/cloud/batch/v1/internal/batch_logging_decorator.cc +++ b/google/cloud/batch/v1/internal/batch_logging_decorator.cc @@ -121,6 +121,74 @@ 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_); +} + +StatusOr +BatchServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr BatchServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status BatchServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status BatchServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..02cbff311ca97 100644 --- a/google/cloud/batch/v1/internal/batch_logging_decorator.h +++ b/google/cloud/batch/v1/internal/batch_logging_decorator.h @@ -69,6 +69,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..5b4a76824822f 100644 --- a/google/cloud/batch/v1/internal/batch_metadata_decorator.cc +++ b/google/cloud/batch/v1/internal/batch_metadata_decorator.cc @@ -106,6 +106,56 @@ 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); +} + +StatusOr +BatchServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr BatchServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status BatchServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status BatchServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..dfa03002eb082 100644 --- a/google/cloud/batch/v1/internal/batch_metadata_decorator.h +++ b/google/cloud/batch/v1/internal/batch_metadata_decorator.h @@ -69,6 +69,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..e34b81e0162d8 100644 --- a/google/cloud/batch/v1/internal/batch_stub.cc +++ b/google/cloud/batch/v1/internal/batch_stub.cc @@ -116,6 +116,75 @@ 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; +} + +StatusOr +DefaultBatchServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultBatchServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultBatchServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultBatchServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..c8ce1a8ba4ed9 100644 --- a/google/cloud/batch/v1/internal/batch_stub.h +++ b/google/cloud/batch/v1/internal/batch_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -68,6 +69,31 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -86,9 +112,16 @@ class DefaultBatchServiceStub : public BatchServiceStub { DefaultBatchServiceStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr CreateJob( grpc::ClientContext& context, Options const& options, @@ -120,6 +153,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -135,6 +192,10 @@ class DefaultBatchServiceStub : public BatchServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..0bb2f4a1f83d5 100644 --- a/google/cloud/batch/v1/internal/batch_stub_factory.cc +++ b/google/cloud/batch/v1/internal/batch_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,14 @@ std::shared_ptr CreateDefaultBatchServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::batch::v1::BatchService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..c7694259c41d5 100644 --- a/google/cloud/batch/v1/internal/batch_tracing_connection.cc +++ b/google/cloud/batch/v1/internal/batch_tracing_connection.cc @@ -99,6 +99,62 @@ 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)); +} + +StreamRange +BatchServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("batch_v1::BatchServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +BatchServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("batch_v1::BatchServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status BatchServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = + internal::MakeSpan("batch_v1::BatchServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status BatchServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("batch_v1::BatchServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..d04e8f7260bee 100644 --- a/google/cloud/batch/v1/internal/batch_tracing_connection.h +++ b/google/cloud/batch/v1/internal/batch_tracing_connection.h @@ -64,6 +64,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..5e4d6c8143c3a 100644 --- a/google/cloud/batch/v1/internal/batch_tracing_stub.cc +++ b/google/cloud/batch/v1/internal/batch_tracing_stub.cc @@ -114,6 +114,75 @@ 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)); +} + +StatusOr +BatchServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.batch.v1.BatchService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr BatchServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.batch.v1.BatchService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status BatchServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.batch.v1.BatchService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status BatchServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.batch.v1.BatchService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..39edbbfcc70e8 100644 --- a/google/cloud/batch/v1/internal/batch_tracing_stub.h +++ b/google/cloud/batch/v1/internal/batch_tracing_stub.h @@ -68,6 +68,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..0d6045f9ae0d4 100644 --- a/google/cloud/batch/v1/mocks/mock_batch_connection.h +++ b/google/cloud/batch/v1/mocks/mock_batch_connection.h @@ -99,6 +99,29 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..b560ce442fbf4 100644 --- a/google/cloud/beyondcorp/appconnections/v1/app_connections_client.cc +++ b/google/cloud/beyondcorp/appconnections/v1/app_connections_client.cc @@ -251,6 +251,101 @@ 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); +} + +StreamRange +AppConnectionsServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +AppConnectionsServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +AppConnectionsServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +AppConnectionsServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status AppConnectionsServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status AppConnectionsServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status AppConnectionsServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status AppConnectionsServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..1050b77a1486c 100644 --- a/google/cloud/beyondcorp/appconnections/v1/app_connections_client.h +++ b/google/cloud/beyondcorp/appconnections/v1/app_connections_client.h @@ -698,6 +698,458 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..3de2e192f450e 100644 --- a/google/cloud/beyondcorp/appconnections/v1/app_connections_connection.cc +++ b/google/cloud/beyondcorp/appconnections/v1/app_connections_connection.cc @@ -143,6 +143,60 @@ 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"); +} + +StreamRange +AppConnectionsServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +AppConnectionsServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AppConnectionsServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AppConnectionsServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeAppConnectionsServiceConnection(Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..e1a313b0ea14b 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,53 @@ 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; +} + +Idempotency AppConnectionsServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AppConnectionsServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AppConnectionsServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AppConnectionsServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..a7add5df1e169 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,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -61,6 +64,33 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..7c1540d34acc6 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,83 @@ 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); +} + +StatusOr +AppConnectionsServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +AppConnectionsServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status AppConnectionsServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status AppConnectionsServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..ae72d2fd8dd87 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..3fcdf1afcd01b 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,171 @@ 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__); +} + +StreamRange +AppConnectionsServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +AppConnectionsServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status AppConnectionsServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status AppConnectionsServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..ea82e4d0edc53 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..7a715d52ec2f4 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,110 @@ 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_); +} + +StatusOr +AppConnectionsServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AppConnectionsServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AppConnectionsServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AppConnectionsServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..8d838adec5920 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..63a7a46960df4 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,86 @@ 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); +} + +StatusOr +AppConnectionsServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +AppConnectionsServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status AppConnectionsServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status AppConnectionsServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..c0aeaa36c2f98 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..5606c720ca42f 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,113 @@ 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; +} + +StatusOr +DefaultAppConnectionsServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAppConnectionsServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultAppConnectionsServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultAppConnectionsServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..47432d6312e19 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,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -92,6 +94,44 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -111,9 +151,18 @@ class DefaultAppConnectionsServiceStub : public AppConnectionsServiceStub { std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +218,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -185,6 +270,11 @@ class DefaultAppConnectionsServiceStub : public AppConnectionsServiceStub { std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..363540a47b886 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,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -46,9 +49,15 @@ CreateDefaultAppConnectionsServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::beyondcorp::appconnections::v1:: AppConnectionsService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..5150845c034e2 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,98 @@ 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)); +} + +StreamRange +AppConnectionsServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "beyondcorp_appconnections_v1::AppConnectionsServiceConnection::" + "ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AppConnectionsServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "beyondcorp_appconnections_v1::AppConnectionsServiceConnection::" + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status AppConnectionsServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "beyondcorp_appconnections_v1::AppConnectionsServiceConnection::" + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status AppConnectionsServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "beyondcorp_appconnections_v1::AppConnectionsServiceConnection::" + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..fb7ef92fc956d 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..a8a1cd0049cec 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,121 @@ 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)); +} + +StatusOr +AppConnectionsServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +AppConnectionsServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status AppConnectionsServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status AppConnectionsServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..4dbc1b436118a 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..6dbd1eb6ca86d 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,42 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..7bad36bc0c9b8 100644 --- a/google/cloud/beyondcorp/appconnectors/v1/app_connectors_client.cc +++ b/google/cloud/beyondcorp/appconnectors/v1/app_connectors_client.cc @@ -280,6 +280,101 @@ 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); +} + +StreamRange +AppConnectorsServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +AppConnectorsServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +AppConnectorsServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +AppConnectorsServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status AppConnectorsServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status AppConnectorsServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status AppConnectorsServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status AppConnectorsServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..24223baaf288c 100644 --- a/google/cloud/beyondcorp/appconnectors/v1/app_connectors_client.h +++ b/google/cloud/beyondcorp/appconnectors/v1/app_connectors_client.h @@ -737,6 +737,458 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..17cefac5d02fb 100644 --- a/google/cloud/beyondcorp/appconnectors/v1/app_connectors_connection.cc +++ b/google/cloud/beyondcorp/appconnectors/v1/app_connectors_connection.cc @@ -156,6 +156,60 @@ 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"); +} + +StreamRange +AppConnectorsServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +AppConnectorsServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AppConnectorsServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AppConnectorsServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeAppConnectorsServiceConnection(Options options) { internal::CheckExpectedOptions> 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..6c027aaaedaa4 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,52 @@ 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; +} + +Idempotency AppConnectorsServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AppConnectorsServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AppConnectorsServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AppConnectorsServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..7e4add7a2232d 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,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -60,6 +63,33 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..83a979d3b7a39 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,82 @@ 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); +} + +StatusOr +AppConnectorsServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr AppConnectorsServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status AppConnectorsServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status AppConnectorsServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..097c69337a3a8 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..d471cf8386fb0 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,171 @@ 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__); +} + +StreamRange +AppConnectorsServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +AppConnectorsServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status AppConnectorsServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status AppConnectorsServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..bcd96cfcce674 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..d015c1cb93615 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,110 @@ 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_); +} + +StatusOr +AppConnectorsServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AppConnectorsServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AppConnectorsServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AppConnectorsServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..edf5080582e16 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..03ea4907257b3 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,86 @@ 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); +} + +StatusOr +AppConnectorsServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +AppConnectorsServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status AppConnectorsServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status AppConnectorsServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..d8618f1049f5b 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..60d5e29cf98cc 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,111 @@ 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; +} + +StatusOr +DefaultAppConnectorsServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAppConnectorsServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultAppConnectorsServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultAppConnectorsServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..424586979b488 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,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -97,6 +99,44 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -116,9 +156,18 @@ class DefaultAppConnectorsServiceStub : public AppConnectorsServiceStub { std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +228,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -195,6 +280,11 @@ class DefaultAppConnectorsServiceStub : public AppConnectorsServiceStub { std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..c883559c11a6d 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,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultAppConnectorsServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::beyondcorp::appconnectors::v1:: AppConnectorsService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..b34f9df2ffdb2 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,98 @@ 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)); +} + +StreamRange +AppConnectorsServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "beyondcorp_appconnectors_v1::AppConnectorsServiceConnection::" + "ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AppConnectorsServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "beyondcorp_appconnectors_v1::AppConnectorsServiceConnection::" + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status AppConnectorsServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "beyondcorp_appconnectors_v1::AppConnectorsServiceConnection::" + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status AppConnectorsServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "beyondcorp_appconnectors_v1::AppConnectorsServiceConnection::" + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..f7821a55eef54 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..87aa44ec1acc0 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,119 @@ 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)); +} + +StatusOr +AppConnectorsServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +AppConnectorsServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status AppConnectorsServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status AppConnectorsServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..12faa23f05eec 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..f90b8fc469b3e 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,42 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..cf172edd55ad0 100644 --- a/google/cloud/beyondcorp/appgateways/v1/app_gateways_client.cc +++ b/google/cloud/beyondcorp/appgateways/v1/app_gateways_client.cc @@ -165,6 +165,99 @@ 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); +} + +StreamRange +AppGatewaysServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +AppGatewaysServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr AppGatewaysServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr AppGatewaysServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status AppGatewaysServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status AppGatewaysServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status AppGatewaysServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status AppGatewaysServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..213eacf595381 100644 --- a/google/cloud/beyondcorp/appgateways/v1/app_gateways_client.h +++ b/google/cloud/beyondcorp/appgateways/v1/app_gateways_client.h @@ -486,6 +486,458 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..56c0545698f00 100644 --- a/google/cloud/beyondcorp/appgateways/v1/app_gateways_connection.cc +++ b/google/cloud/beyondcorp/appgateways/v1/app_gateways_connection.cc @@ -104,6 +104,60 @@ 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"); +} + +StreamRange +AppGatewaysServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +AppGatewaysServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AppGatewaysServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AppGatewaysServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeAppGatewaysServiceConnection( Options options) { internal::CheckExpectedOptions> 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..e0e812d78c796 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,52 @@ 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; +} + +Idempotency AppGatewaysServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AppGatewaysServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AppGatewaysServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AppGatewaysServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..413008cb33a4c 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,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -52,6 +55,33 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..bce20174bbbf3 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,81 @@ 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); +} + +StatusOr +AppGatewaysServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr AppGatewaysServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status AppGatewaysServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status AppGatewaysServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..1817a6e3e65d0 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..2df3d7b16d935 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,171 @@ 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__); +} + +StreamRange +AppGatewaysServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +AppGatewaysServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status AppGatewaysServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status AppGatewaysServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..d83207209b50c 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..334a70137cca1 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,110 @@ 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_); +} + +StatusOr +AppGatewaysServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AppGatewaysServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AppGatewaysServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AppGatewaysServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..2bb57552f98b7 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..240458625edbe 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,86 @@ 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); +} + +StatusOr +AppGatewaysServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +AppGatewaysServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status AppGatewaysServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status AppGatewaysServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..7b1b60c901def 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..7fd4ac3a89e93 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,111 @@ 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; +} + +StatusOr +DefaultAppGatewaysServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAppGatewaysServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultAppGatewaysServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultAppGatewaysServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..66b4957a34f5f 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,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -77,6 +79,44 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -96,9 +136,18 @@ class DefaultAppGatewaysServiceStub : public AppGatewaysServiceStub { std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListAppGateways( @@ -136,6 +185,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -152,6 +237,11 @@ class DefaultAppGatewaysServiceStub : public AppGatewaysServiceStub { std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..fc43161af5d0e 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,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -45,9 +48,15 @@ std::shared_ptr CreateDefaultAppGatewaysServiceStub( auto service_grpc_stub = google::cloud::beyondcorp::appgateways::v1::AppGatewaysService::NewStub( channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..c349cf6cf3e3a 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,93 @@ 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)); +} + +StreamRange +AppGatewaysServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "beyondcorp_appgateways_v1::AppGatewaysServiceConnection::" + "ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AppGatewaysServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "beyondcorp_appgateways_v1::AppGatewaysServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status AppGatewaysServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "beyondcorp_appgateways_v1::AppGatewaysServiceConnection::" + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status AppGatewaysServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "beyondcorp_appgateways_v1::AppGatewaysServiceConnection::" + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..d9ac514a90782 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..d476254114146 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,119 @@ 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)); +} + +StatusOr +AppGatewaysServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +AppGatewaysServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status AppGatewaysServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status AppGatewaysServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..b5fac507432e1 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..f30f7199cfe62 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,42 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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 230dff97c56c3..32f6a1fc5f640 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 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..e5a05f61be1e5 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,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -129,6 +130,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 +146,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 +242,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..804b43a0a05d7 100644 --- a/google/cloud/certificatemanager/v1/certificate_manager_client.cc +++ b/google/cloud/certificatemanager/v1/certificate_manager_client.cc @@ -1096,6 +1096,80 @@ 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); +} + +StreamRange +CertificateManagerClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +CertificateManagerClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr CertificateManagerClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr CertificateManagerClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status CertificateManagerClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status CertificateManagerClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status CertificateManagerClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status CertificateManagerClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..e7836aa857f8f 100644 --- a/google/cloud/certificatemanager/v1/certificate_manager_client.h +++ b/google/cloud/certificatemanager/v1/certificate_manager_client.h @@ -3003,6 +3003,356 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..5f93f396edea2 100644 --- a/google/cloud/certificatemanager/v1/certificate_manager_connection.cc +++ b/google/cloud/certificatemanager/v1/certificate_manager_connection.cc @@ -542,6 +542,44 @@ 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"); +} + +StreamRange +CertificateManagerConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +CertificateManagerConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status CertificateManagerConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status CertificateManagerConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeCertificateManagerConnection( Options options) { internal::CheckExpectedOptions> DeleteTrustConfig(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..a9b7cdeeb2a35 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,36 @@ 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; +} + +Idempotency CertificateManagerConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency CertificateManagerConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency CertificateManagerConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency CertificateManagerConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..b1a745714b3b9 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -150,6 +152,24 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..a3bae677bca52 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,56 @@ 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); +} + +StatusOr +CertificateManagerAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr CertificateManagerAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status CertificateManagerAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status CertificateManagerAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..1e5829314f6b0 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..68b3a14191678 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,129 @@ 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__); +} + +StreamRange +CertificateManagerConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +CertificateManagerConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status CertificateManagerConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status CertificateManagerConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..be19bdea8cc1e 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..591a5000c9575 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,76 @@ 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_); +} + +StatusOr +CertificateManagerLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +CertificateManagerLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status CertificateManagerLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status CertificateManagerLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..978cdfaca23d7 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..e09e52d21d8ea 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,58 @@ 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); +} + +StatusOr +CertificateManagerMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +CertificateManagerMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status CertificateManagerMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status CertificateManagerMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..66ed5b7fa8870 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..242dfac07a95c 100644 --- a/google/cloud/certificatemanager/v1/internal/certificate_manager_stub.cc +++ b/google/cloud/certificatemanager/v1/internal/certificate_manager_stub.cc @@ -772,6 +772,76 @@ 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; +} + +StatusOr +DefaultCertificateManagerStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultCertificateManagerStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultCertificateManagerStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultCertificateManagerStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..3b3f3083fb580 100644 --- a/google/cloud/certificatemanager/v1/internal/certificate_manager_stub.h +++ b/google/cloud/certificatemanager/v1/internal/certificate_manager_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -339,6 +340,31 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -358,9 +384,16 @@ class DefaultCertificateManagerStub : public CertificateManagerStub { std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListCertificates( @@ -643,6 +676,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -659,6 +716,10 @@ class DefaultCertificateManagerStub : public CertificateManagerStub { std::unique_ptr< google::cloud::certificatemanager::v1::CertificateManager::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..4fe99d145101a 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -45,9 +47,14 @@ std::shared_ptr CreateDefaultCertificateManagerStub( auto service_grpc_stub = google::cloud::certificatemanager::v1::CertificateManager::NewStub( channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..831047687ff3a 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,62 @@ 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)); +} + +StreamRange +CertificateManagerTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "certificatemanager_v1::CertificateManagerConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +CertificateManagerTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "certificatemanager_v1::CertificateManagerConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status CertificateManagerTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "certificatemanager_v1::CertificateManagerConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status CertificateManagerTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "certificatemanager_v1::CertificateManagerConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..38c1b6e930f8d 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..2c0ace27ebc16 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,79 @@ 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)); +} + +StatusOr +CertificateManagerTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.certificatemanager.v1.CertificateManager", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +CertificateManagerTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.certificatemanager.v1.CertificateManager", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status CertificateManagerTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.certificatemanager.v1.CertificateManager", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status CertificateManagerTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.certificatemanager.v1.CertificateManager", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..fd2e5c3b1e866 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..9ae02e1ad64eb 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,29 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/channel/v1/cloud_channel_client.cc b/google/cloud/channel/v1/cloud_channel_client.cc index 7078133c00c7a..36d51f3579d68 100644 --- a/google/cloud/channel/v1/cloud_channel_client.cc +++ b/google/cloud/channel/v1/cloud_channel_client.cc @@ -748,6 +748,67 @@ CloudChannelServiceClient::ListEntitlementChanges( return connection_->ListEntitlementChanges(std::move(request)); } +StreamRange +CloudChannelServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +CloudChannelServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +CloudChannelServiceClient::GetOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +CloudChannelServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status CloudChannelServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status CloudChannelServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status CloudChannelServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status CloudChannelServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace channel_v1 } // namespace cloud diff --git a/google/cloud/channel/v1/cloud_channel_client.h b/google/cloud/channel/v1/cloud_channel_client.h index 75f7be777f4c2..8ff25319d93b3 100644 --- a/google/cloud/channel/v1/cloud_channel_client.h +++ b/google/cloud/channel/v1/cloud_channel_client.h @@ -3940,6 +3940,286 @@ class CloudChannelServiceClient { google::cloud::channel::v1::ListEntitlementChangesRequest request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/channel/v1/cloud_channel_connection.cc b/google/cloud/channel/v1/cloud_channel_connection.cc index b46f1e7afe704..312bef20a2887 100644 --- a/google/cloud/channel/v1/cloud_channel_connection.cc +++ b/google/cloud/channel/v1/cloud_channel_connection.cc @@ -555,6 +555,30 @@ CloudChannelServiceConnection::ListEntitlementChanges( StreamRange>(); } +StreamRange +CloudChannelServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +CloudChannelServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status CloudChannelServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status CloudChannelServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeCloudChannelServiceConnection(Options options) { internal::CheckExpectedOptions ListEntitlementChanges( google::cloud::channel::v1::ListEntitlementChangesRequest request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/channel/v1/cloud_channel_connection_idempotency_policy.cc b/google/cloud/channel/v1/cloud_channel_connection_idempotency_policy.cc index 05944eef285ff..c29ed7a4ecd8a 100644 --- a/google/cloud/channel/v1/cloud_channel_connection_idempotency_policy.cc +++ b/google/cloud/channel/v1/cloud_channel_connection_idempotency_policy.cc @@ -312,6 +312,26 @@ CloudChannelServiceConnectionIdempotencyPolicy::ListEntitlementChanges( return Idempotency::kIdempotent; } +Idempotency CloudChannelServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency CloudChannelServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency CloudChannelServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency CloudChannelServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultCloudChannelServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/channel/v1/cloud_channel_connection_idempotency_policy.h b/google/cloud/channel/v1/cloud_channel_connection_idempotency_policy.h index 047cabeb991a8..62d4db160aa35 100644 --- a/google/cloud/channel/v1/cloud_channel_connection_idempotency_policy.h +++ b/google/cloud/channel/v1/cloud_channel_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -197,6 +198,18 @@ class CloudChannelServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListEntitlementChanges( google::cloud::channel::v1::ListEntitlementChangesRequest request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/channel/v1/cloud_channel_reports_client.cc b/google/cloud/channel/v1/cloud_channel_reports_client.cc index a5205cd089cce..48de414b35fb1 100644 --- a/google/cloud/channel/v1/cloud_channel_reports_client.cc +++ b/google/cloud/channel/v1/cloud_channel_reports_client.cc @@ -89,6 +89,68 @@ CloudChannelReportsServiceClient::ListReports( return connection_->ListReports(std::move(request)); } +StreamRange +CloudChannelReportsServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +CloudChannelReportsServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +CloudChannelReportsServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +CloudChannelReportsServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status CloudChannelReportsServiceClient::DeleteOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status CloudChannelReportsServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status CloudChannelReportsServiceClient::CancelOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status CloudChannelReportsServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace channel_v1 } // namespace cloud diff --git a/google/cloud/channel/v1/cloud_channel_reports_client.h b/google/cloud/channel/v1/cloud_channel_reports_client.h index 569a3438b3570..ad8295c16ab80 100644 --- a/google/cloud/channel/v1/cloud_channel_reports_client.h +++ b/google/cloud/channel/v1/cloud_channel_reports_client.h @@ -392,6 +392,286 @@ class CloudChannelReportsServiceClient { google::cloud::channel::v1::ListReportsRequest request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/channel/v1/cloud_channel_reports_connection.cc b/google/cloud/channel/v1/cloud_channel_reports_connection.cc index b9cb2dfa9b466..dc14ad37ba0ee 100644 --- a/google/cloud/channel/v1/cloud_channel_reports_connection.cc +++ b/google/cloud/channel/v1/cloud_channel_reports_connection.cc @@ -78,6 +78,30 @@ CloudChannelReportsServiceConnection::ListReports( StreamRange>(); } +StreamRange +CloudChannelReportsServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +CloudChannelReportsServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status CloudChannelReportsServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status CloudChannelReportsServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeCloudChannelReportsServiceConnection(Options options) { internal::CheckExpectedOptions ListReports( google::cloud::channel::v1::ListReportsRequest request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/channel/v1/cloud_channel_reports_connection_idempotency_policy.cc b/google/cloud/channel/v1/cloud_channel_reports_connection_idempotency_policy.cc index 05a28fc321cde..a7d2ad092e2c8 100644 --- a/google/cloud/channel/v1/cloud_channel_reports_connection_idempotency_policy.cc +++ b/google/cloud/channel/v1/cloud_channel_reports_connection_idempotency_policy.cc @@ -51,6 +51,29 @@ Idempotency CloudChannelReportsServiceConnectionIdempotencyPolicy::ListReports( return Idempotency::kIdempotent; } +Idempotency +CloudChannelReportsServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency CloudChannelReportsServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +CloudChannelReportsServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency +CloudChannelReportsServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultCloudChannelReportsServiceConnectionIdempotencyPolicy() { return std::make_unique< diff --git a/google/cloud/channel/v1/cloud_channel_reports_connection_idempotency_policy.h b/google/cloud/channel/v1/cloud_channel_reports_connection_idempotency_policy.h index ad85aa75119c8..a6a7424863161 100644 --- a/google/cloud/channel/v1/cloud_channel_reports_connection_idempotency_policy.h +++ b/google/cloud/channel/v1/cloud_channel_reports_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,18 @@ class CloudChannelReportsServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListReports( google::cloud::channel::v1::ListReportsRequest request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/channel/v1/internal/cloud_channel_auth_decorator.cc b/google/cloud/channel/v1/internal/cloud_channel_auth_decorator.cc index c53706f494b20..4a0cc61e80317 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_auth_decorator.cc +++ b/google/cloud/channel/v1/internal/cloud_channel_auth_decorator.cc @@ -705,6 +705,39 @@ CloudChannelServiceAuth::ListEntitlementChanges( return child_->ListEntitlementChanges(context, options, request); } +StatusOr +CloudChannelServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr CloudChannelServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status CloudChannelServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status CloudChannelServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + future> CloudChannelServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/channel/v1/internal/cloud_channel_auth_decorator.h b/google/cloud/channel/v1/internal/cloud_channel_auth_decorator.h index 902a4b25a8ad1..aee4d6b999693 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_auth_decorator.h +++ b/google/cloud/channel/v1/internal/cloud_channel_auth_decorator.h @@ -375,6 +375,22 @@ class CloudChannelServiceAuth : public CloudChannelServiceStub { google::cloud::channel::v1::ListEntitlementChangesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/channel/v1/internal/cloud_channel_connection_impl.cc b/google/cloud/channel/v1/internal/cloud_channel_connection_impl.cc index 031b597a6d85a..e9a66f03acca8 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_connection_impl.cc +++ b/google/cloud/channel/v1/internal/cloud_channel_connection_impl.cc @@ -1979,6 +1979,79 @@ CloudChannelServiceConnectionImpl::ListEntitlementChanges( }); } +StreamRange +CloudChannelServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +CloudChannelServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status CloudChannelServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status CloudChannelServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace channel_v1_internal } // namespace cloud diff --git a/google/cloud/channel/v1/internal/cloud_channel_connection_impl.h b/google/cloud/channel/v1/internal/cloud_channel_connection_impl.h index b7d181264251b..ead015cc32d79 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_connection_impl.h +++ b/google/cloud/channel/v1/internal/cloud_channel_connection_impl.h @@ -346,6 +346,18 @@ class CloudChannelServiceConnectionImpl google::cloud::channel::v1::ListEntitlementChangesRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/channel/v1/internal/cloud_channel_logging_decorator.cc b/google/cloud/channel/v1/internal/cloud_channel_logging_decorator.cc index 3060931d2ecc4..9588713bda69c 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_logging_decorator.cc +++ b/google/cloud/channel/v1/internal/cloud_channel_logging_decorator.cc @@ -892,6 +892,52 @@ CloudChannelServiceLogging::ListEntitlementChanges( context, options, request, __func__, tracing_options_); } +StatusOr +CloudChannelServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +CloudChannelServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status CloudChannelServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status CloudChannelServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> CloudChannelServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/channel/v1/internal/cloud_channel_logging_decorator.h b/google/cloud/channel/v1/internal/cloud_channel_logging_decorator.h index ed9a06372217a..7aa2607885ef5 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_logging_decorator.h +++ b/google/cloud/channel/v1/internal/cloud_channel_logging_decorator.h @@ -375,6 +375,22 @@ class CloudChannelServiceLogging : public CloudChannelServiceStub { google::cloud::channel::v1::ListEntitlementChangesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/channel/v1/internal/cloud_channel_metadata_decorator.cc b/google/cloud/channel/v1/internal/cloud_channel_metadata_decorator.cc index 48fcf860ca5b6..2e7206be445c1 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_metadata_decorator.cc +++ b/google/cloud/channel/v1/internal/cloud_channel_metadata_decorator.cc @@ -642,6 +642,40 @@ CloudChannelServiceMetadata::ListEntitlementChanges( return child_->ListEntitlementChanges(context, options, request); } +StatusOr +CloudChannelServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +CloudChannelServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status CloudChannelServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status CloudChannelServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + future> CloudChannelServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/channel/v1/internal/cloud_channel_metadata_decorator.h b/google/cloud/channel/v1/internal/cloud_channel_metadata_decorator.h index f95edd6b168b8..d78046e855f1e 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_metadata_decorator.h +++ b/google/cloud/channel/v1/internal/cloud_channel_metadata_decorator.h @@ -376,6 +376,22 @@ class CloudChannelServiceMetadata : public CloudChannelServiceStub { google::cloud::channel::v1::ListEntitlementChangesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/channel/v1/internal/cloud_channel_reports_auth_decorator.cc b/google/cloud/channel/v1/internal/cloud_channel_reports_auth_decorator.cc index f6f525fc16f5d..de6c83addd0f7 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_reports_auth_decorator.cc +++ b/google/cloud/channel/v1/internal/cloud_channel_reports_auth_decorator.cc @@ -78,6 +78,40 @@ CloudChannelReportsServiceAuth::ListReports( return child_->ListReports(context, options, request); } +StatusOr +CloudChannelReportsServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +CloudChannelReportsServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status CloudChannelReportsServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status CloudChannelReportsServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + future> CloudChannelReportsServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/channel/v1/internal/cloud_channel_reports_auth_decorator.h b/google/cloud/channel/v1/internal/cloud_channel_reports_auth_decorator.h index 5c8cf5881cb22..e85a1f1fa6850 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_reports_auth_decorator.h +++ b/google/cloud/channel/v1/internal/cloud_channel_reports_auth_decorator.h @@ -59,6 +59,22 @@ class CloudChannelReportsServiceAuth : public CloudChannelReportsServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::channel::v1::ListReportsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/channel/v1/internal/cloud_channel_reports_connection_impl.cc b/google/cloud/channel/v1/internal/cloud_channel_reports_connection_impl.cc index 4672c950cd5c8..cc83bc433b1bf 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_reports_connection_impl.cc +++ b/google/cloud/channel/v1/internal/cloud_channel_reports_connection_impl.cc @@ -234,6 +234,80 @@ CloudChannelReportsServiceConnectionImpl::ListReports( }); } +StreamRange +CloudChannelReportsServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +CloudChannelReportsServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status CloudChannelReportsServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status CloudChannelReportsServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace channel_v1_internal } // namespace cloud diff --git a/google/cloud/channel/v1/internal/cloud_channel_reports_connection_impl.h b/google/cloud/channel/v1/internal/cloud_channel_reports_connection_impl.h index 3bd1992e9402d..bcbb394c2a822 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_reports_connection_impl.h +++ b/google/cloud/channel/v1/internal/cloud_channel_reports_connection_impl.h @@ -69,6 +69,18 @@ class CloudChannelReportsServiceConnectionImpl StreamRange ListReports( google::cloud::channel::v1::ListReportsRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/channel/v1/internal/cloud_channel_reports_logging_decorator.cc b/google/cloud/channel/v1/internal/cloud_channel_reports_logging_decorator.cc index b555a4b2c0e19..ae543652e5b16 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_reports_logging_decorator.cc +++ b/google/cloud/channel/v1/internal/cloud_channel_reports_logging_decorator.cc @@ -90,6 +90,52 @@ CloudChannelReportsServiceLogging::ListReports( context, options, request, __func__, tracing_options_); } +StatusOr +CloudChannelReportsServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +CloudChannelReportsServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status CloudChannelReportsServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status CloudChannelReportsServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> CloudChannelReportsServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/channel/v1/internal/cloud_channel_reports_logging_decorator.h b/google/cloud/channel/v1/internal/cloud_channel_reports_logging_decorator.h index 7ee8be5c42530..3f684aee67146 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_reports_logging_decorator.h +++ b/google/cloud/channel/v1/internal/cloud_channel_reports_logging_decorator.h @@ -60,6 +60,22 @@ class CloudChannelReportsServiceLogging grpc::ClientContext& context, Options const& options, google::cloud::channel::v1::ListReportsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/channel/v1/internal/cloud_channel_reports_metadata_decorator.cc b/google/cloud/channel/v1/internal/cloud_channel_reports_metadata_decorator.cc index 1900e4bfc7995..bc044f97300f5 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_reports_metadata_decorator.cc +++ b/google/cloud/channel/v1/internal/cloud_channel_reports_metadata_decorator.cc @@ -84,6 +84,40 @@ CloudChannelReportsServiceMetadata::ListReports( return child_->ListReports(context, options, request); } +StatusOr +CloudChannelReportsServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +CloudChannelReportsServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status CloudChannelReportsServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status CloudChannelReportsServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + future> CloudChannelReportsServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/channel/v1/internal/cloud_channel_reports_metadata_decorator.h b/google/cloud/channel/v1/internal/cloud_channel_reports_metadata_decorator.h index f671e9cbd2e50..f5dcf7a0088e1 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_reports_metadata_decorator.h +++ b/google/cloud/channel/v1/internal/cloud_channel_reports_metadata_decorator.h @@ -61,6 +61,22 @@ class CloudChannelReportsServiceMetadata grpc::ClientContext& context, Options const& options, google::cloud::channel::v1::ListReportsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/channel/v1/internal/cloud_channel_reports_stub.cc b/google/cloud/channel/v1/internal/cloud_channel_reports_stub.cc index b78c7a3743956..7edbc5ad92170 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_reports_stub.cc +++ b/google/cloud/channel/v1/internal/cloud_channel_reports_stub.cc @@ -85,6 +85,52 @@ DefaultCloudChannelReportsServiceStub::ListReports( return response; } +StatusOr +DefaultCloudChannelReportsServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultCloudChannelReportsServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultCloudChannelReportsServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultCloudChannelReportsServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + future> DefaultCloudChannelReportsServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/channel/v1/internal/cloud_channel_reports_stub.h b/google/cloud/channel/v1/internal/cloud_channel_reports_stub.h index e3ee6e2ad80d8..a1600a00323d0 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_reports_stub.h +++ b/google/cloud/channel/v1/internal/cloud_channel_reports_stub.h @@ -58,6 +58,22 @@ class CloudChannelReportsServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::channel::v1::ListReportsRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -78,9 +94,13 @@ class DefaultCloudChannelReportsServiceStub std::unique_ptr< google::cloud::channel::v1::CloudChannelReportsService::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} future> AsyncRunReportJob( google::cloud::CompletionQueue& cq, @@ -102,6 +122,22 @@ class DefaultCloudChannelReportsServiceStub grpc::ClientContext& context, Options const& options, google::cloud::channel::v1::ListReportsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -118,6 +154,8 @@ class DefaultCloudChannelReportsServiceStub std::unique_ptr< google::cloud::channel::v1::CloudChannelReportsService::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/channel/v1/internal/cloud_channel_reports_stub_factory.cc b/google/cloud/channel/v1/internal/cloud_channel_reports_stub_factory.cc index 6aebc5376bdf8..00cd0eda4b161 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_reports_stub_factory.cc +++ b/google/cloud/channel/v1/internal/cloud_channel_reports_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 @@ CreateDefaultCloudChannelReportsServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::channel::v1::CloudChannelReportsService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/channel/v1/internal/cloud_channel_reports_tracing_connection.cc b/google/cloud/channel/v1/internal/cloud_channel_reports_tracing_connection.cc index 8dd6dcb37e5f5..b81bc97be669e 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_reports_tracing_connection.cc +++ b/google/cloud/channel/v1/internal/cloud_channel_reports_tracing_connection.cc @@ -84,6 +84,42 @@ CloudChannelReportsServiceTracingConnection::ListReports( std::move(span), std::move(sr)); } +StreamRange +CloudChannelReportsServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "channel_v1::CloudChannelReportsServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +CloudChannelReportsServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "channel_v1::CloudChannelReportsServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status CloudChannelReportsServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "channel_v1::CloudChannelReportsServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status CloudChannelReportsServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "channel_v1::CloudChannelReportsServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/channel/v1/internal/cloud_channel_reports_tracing_connection.h b/google/cloud/channel/v1/internal/cloud_channel_reports_tracing_connection.h index 00f444d01f500..1e76d8af0e401 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_reports_tracing_connection.h +++ b/google/cloud/channel/v1/internal/cloud_channel_reports_tracing_connection.h @@ -57,6 +57,18 @@ class CloudChannelReportsServiceTracingConnection StreamRange ListReports( google::cloud::channel::v1::ListReportsRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/channel/v1/internal/cloud_channel_reports_tracing_stub.cc b/google/cloud/channel/v1/internal/cloud_channel_reports_tracing_stub.cc index aee0cb7686800..ce153912ae552 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_reports_tracing_stub.cc +++ b/google/cloud/channel/v1/internal/cloud_channel_reports_tracing_stub.cc @@ -83,6 +83,52 @@ CloudChannelReportsServiceTracingStub::ListReports( child_->ListReports(context, options, request)); } +StatusOr +CloudChannelReportsServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.channel.v1.CloudChannelReportsService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +CloudChannelReportsServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.channel.v1.CloudChannelReportsService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status CloudChannelReportsServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.channel.v1.CloudChannelReportsService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status CloudChannelReportsServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.channel.v1.CloudChannelReportsService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + future> CloudChannelReportsServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/channel/v1/internal/cloud_channel_reports_tracing_stub.h b/google/cloud/channel/v1/internal/cloud_channel_reports_tracing_stub.h index 308fedb34ce16..14bf63f41bc3e 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_reports_tracing_stub.h +++ b/google/cloud/channel/v1/internal/cloud_channel_reports_tracing_stub.h @@ -60,6 +60,22 @@ class CloudChannelReportsServiceTracingStub grpc::ClientContext& context, Options const& options, google::cloud::channel::v1::ListReportsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/channel/v1/internal/cloud_channel_stub.cc b/google/cloud/channel/v1/internal/cloud_channel_stub.cc index ac56b1a3c6096..7d9825011c783 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_stub.cc +++ b/google/cloud/channel/v1/internal/cloud_channel_stub.cc @@ -862,6 +862,52 @@ DefaultCloudChannelServiceStub::ListEntitlementChanges( return response; } +StatusOr +DefaultCloudChannelServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultCloudChannelServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultCloudChannelServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultCloudChannelServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + future> DefaultCloudChannelServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/channel/v1/internal/cloud_channel_stub.h b/google/cloud/channel/v1/internal/cloud_channel_stub.h index bf0cb5db34691..e010a6cd5a62e 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_stub.h +++ b/google/cloud/channel/v1/internal/cloud_channel_stub.h @@ -375,6 +375,22 @@ class CloudChannelServiceStub { google::cloud::channel::v1::ListEntitlementChangesRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -394,9 +410,13 @@ class DefaultCloudChannelServiceStub : public CloudChannelServiceStub { std::unique_ptr< google::cloud::channel::v1::CloudChannelService::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr ListCustomers( grpc::ClientContext& context, Options const& options, @@ -734,6 +754,22 @@ class DefaultCloudChannelServiceStub : public CloudChannelServiceStub { google::cloud::channel::v1::ListEntitlementChangesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -750,6 +786,8 @@ class DefaultCloudChannelServiceStub : public CloudChannelServiceStub { std::unique_ptr< google::cloud::channel::v1::CloudChannelService::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/channel/v1/internal/cloud_channel_stub_factory.cc b/google/cloud/channel/v1/internal/cloud_channel_stub_factory.cc index 38a5bc1d0ac40..b15dc80a89bc4 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_stub_factory.cc +++ b/google/cloud/channel/v1/internal/cloud_channel_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 CreateDefaultCloudChannelServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::channel::v1::CloudChannelService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/channel/v1/internal/cloud_channel_tracing_connection.cc b/google/cloud/channel/v1/internal/cloud_channel_tracing_connection.cc index 621d72e2352a6..672ae3d06a808 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_tracing_connection.cc +++ b/google/cloud/channel/v1/internal/cloud_channel_tracing_connection.cc @@ -783,6 +783,42 @@ CloudChannelServiceTracingConnection::ListEntitlementChanges( std::move(sr)); } +StreamRange +CloudChannelServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "channel_v1::CloudChannelServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +CloudChannelServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "channel_v1::CloudChannelServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status CloudChannelServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "channel_v1::CloudChannelServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status CloudChannelServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "channel_v1::CloudChannelServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/channel/v1/internal/cloud_channel_tracing_connection.h b/google/cloud/channel/v1/internal/cloud_channel_tracing_connection.h index 8e1341c832ea6..6d26fbb179696 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_tracing_connection.h +++ b/google/cloud/channel/v1/internal/cloud_channel_tracing_connection.h @@ -334,6 +334,18 @@ class CloudChannelServiceTracingConnection google::cloud::channel::v1::ListEntitlementChangesRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/channel/v1/internal/cloud_channel_tracing_stub.cc b/google/cloud/channel/v1/internal/cloud_channel_tracing_stub.cc index 96aa46d523463..02c87a30d0370 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_tracing_stub.cc +++ b/google/cloud/channel/v1/internal/cloud_channel_tracing_stub.cc @@ -835,6 +835,52 @@ CloudChannelServiceTracingStub::ListEntitlementChanges( child_->ListEntitlementChanges(context, options, request)); } +StatusOr +CloudChannelServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.channel.v1.CloudChannelService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +CloudChannelServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.channel.v1.CloudChannelService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status CloudChannelServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.channel.v1.CloudChannelService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status CloudChannelServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.channel.v1.CloudChannelService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + future> CloudChannelServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/channel/v1/internal/cloud_channel_tracing_stub.h b/google/cloud/channel/v1/internal/cloud_channel_tracing_stub.h index d8500d3334a46..3842087878f33 100644 --- a/google/cloud/channel/v1/internal/cloud_channel_tracing_stub.h +++ b/google/cloud/channel/v1/internal/cloud_channel_tracing_stub.h @@ -375,6 +375,22 @@ class CloudChannelServiceTracingStub : public CloudChannelServiceStub { google::cloud::channel::v1::ListEntitlementChangesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/channel/v1/mocks/mock_cloud_channel_connection.h b/google/cloud/channel/v1/mocks/mock_cloud_channel_connection.h index c54c3592a350c..b3f3976e0e55e 100644 --- a/google/cloud/channel/v1/mocks/mock_cloud_channel_connection.h +++ b/google/cloud/channel/v1/mocks/mock_cloud_channel_connection.h @@ -697,6 +697,21 @@ class MockCloudChannelServiceConnection ListEntitlementChanges, (google::cloud::channel::v1::ListEntitlementChangesRequest request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/channel/v1/mocks/mock_cloud_channel_reports_connection.h b/google/cloud/channel/v1/mocks/mock_cloud_channel_reports_connection.h index 63ff37f2c82b6..7e371da033dc3 100644 --- a/google/cloud/channel/v1/mocks/mock_cloud_channel_reports_connection.h +++ b/google/cloud/channel/v1/mocks/mock_cloud_channel_reports_connection.h @@ -94,6 +94,21 @@ class MockCloudChannelReportsServiceConnection MOCK_METHOD((StreamRange), ListReports, (google::cloud::channel::v1::ListReportsRequest request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..9e138c0b78e32 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,47 @@ 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); +} + +StatusOr RepositoryManagerAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status RepositoryManagerAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..6e6c9f24314cc 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,26 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..5f572df2f7351 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,73 @@ 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__); +} + +StatusOr +RepositoryManagerConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status RepositoryManagerConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..5e52aa52ac165 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,21 @@ 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; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..02145614dd495 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,62 @@ 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_); +} + +StatusOr RepositoryManagerLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status RepositoryManagerLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..ebed4bf03e31c 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,26 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..c41d0353f572d 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,51 @@ 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); +} + +StatusOr +RepositoryManagerMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status RepositoryManagerMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..e5fc51ee14216 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,26 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..9b7c4abb58dd9 100644 --- a/google/cloud/cloudbuild/v2/internal/repository_manager_stub.cc +++ b/google/cloud/cloudbuild/v2/internal/repository_manager_stub.cc @@ -319,6 +319,64 @@ 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; +} + +StatusOr +DefaultRepositoryManagerStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultRepositoryManagerStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..e4af1716bd9b9 100644 --- a/google/cloud/cloudbuild/v2/internal/repository_manager_stub.h +++ b/google/cloud/cloudbuild/v2/internal/repository_manager_stub.h @@ -26,6 +26,7 @@ #include "google/cloud/version.h" #include #include +#include #include #include #include @@ -163,6 +164,27 @@ 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 StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -182,9 +204,15 @@ class DefaultRepositoryManagerStub : public RepositoryManagerStub { std::unique_ptr< google::devtools::cloudbuild::v2::RepositoryManager::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + operations_(std::move(operations)) {} future> AsyncCreateConnection( google::cloud::CompletionQueue& cq, @@ -302,6 +330,26 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -318,6 +366,9 @@ class DefaultRepositoryManagerStub : public RepositoryManagerStub { std::unique_ptr< google::devtools::cloudbuild::v2::RepositoryManager::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..5e57d7e1a4003 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultRepositoryManagerStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::devtools::cloudbuild::v2::RepositoryManager::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..8baa92ccfb81b 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,50 @@ 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)); +} + +StatusOr +RepositoryManagerTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "cloudbuild_v2::RepositoryManagerConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status RepositoryManagerTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "cloudbuild_v2::RepositoryManagerConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..30ce486e4f321 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,21 @@ 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; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..0c659197212db 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,63 @@ 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)); +} + +StatusOr +RepositoryManagerTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.devtools.cloudbuild.v2.RepositoryManager", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status RepositoryManagerTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.devtools.cloudbuild.v2.RepositoryManager", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..4d59563cee158 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,26 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..0c9ce61fbd3f1 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,27 @@ 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)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..4ba947d778e18 100644 --- a/google/cloud/cloudbuild/v2/repository_manager_client.cc +++ b/google/cloud/cloudbuild/v2/repository_manager_client.cc @@ -444,6 +444,53 @@ 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); +} + +StatusOr RepositoryManagerClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr RepositoryManagerClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status RepositoryManagerClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status RepositoryManagerClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..a3624cc99d350 100644 --- a/google/cloud/cloudbuild/v2/repository_manager_client.h +++ b/google/cloud/cloudbuild/v2/repository_manager_client.h @@ -1302,6 +1302,241 @@ 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 = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..3525e3b77641d 100644 --- a/google/cloud/cloudbuild/v2/repository_manager_connection.cc +++ b/google/cloud/cloudbuild/v2/repository_manager_connection.cc @@ -238,6 +238,33 @@ 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"); +} + +StatusOr +RepositoryManagerConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status RepositoryManagerConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeRepositoryManagerConnection( Options options) { internal::CheckExpectedOptions 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); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..88974ab204d12 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,32 @@ 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; +} + +Idempotency RepositoryManagerConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency RepositoryManagerConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..5a49d8264f8be 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -81,6 +83,21 @@ 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); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_client.cc b/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_client.cc index 77798d4c6b435..2313196bb4aaf 100644 --- a/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_client.cc +++ b/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_client.cc @@ -96,6 +96,22 @@ ConsumerProcurementServiceClient::ListOrders( return connection_->ListOrders(std::move(request)); } +StatusOr +ConsumerProcurementServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +ConsumerProcurementServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace commerce_consumer_procurement_v1 } // namespace cloud diff --git a/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_client.h b/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_client.h index 535443aca865f..7f65b29297121 100644 --- a/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_client.h +++ b/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_client.h @@ -323,6 +323,66 @@ class ConsumerProcurementServiceClient { request, Options opts = {}); + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_connection.cc b/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_connection.cc index e6ef52813cfb7..1bce3fda857e4 100644 --- a/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_connection.cc +++ b/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_connection.cc @@ -80,6 +80,12 @@ ConsumerProcurementServiceConnection::ListOrders( StreamRange>(); } +StatusOr +ConsumerProcurementServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeConsumerProcurementServiceConnection(Options options) { internal::CheckExpectedOptions GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_connection_idempotency_policy.cc b/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_connection_idempotency_policy.cc index 727cb6e1ceb86..7803537bb34bc 100644 --- a/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_connection_idempotency_policy.cc +++ b/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_connection_idempotency_policy.cc @@ -54,6 +54,11 @@ Idempotency ConsumerProcurementServiceConnectionIdempotencyPolicy::ListOrders( return Idempotency::kIdempotent; } +Idempotency ConsumerProcurementServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultConsumerProcurementServiceConnectionIdempotencyPolicy() { return std::make_unique< diff --git a/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_connection_idempotency_policy.h b/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_connection_idempotency_policy.h index e6864b7e27569..8a9b4a7f2b7c5 100644 --- a/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_connection_idempotency_policy.h +++ b/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_connection_idempotency_policy.h @@ -23,6 +23,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -49,6 +50,9 @@ class ConsumerProcurementServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListOrders( google::cloud::commerce::consumer::procurement::v1::ListOrdersRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_auth_decorator.cc b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_auth_decorator.cc index 4b25382d0e39c..148f7619f1d5d 100644 --- a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_auth_decorator.cc +++ b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_auth_decorator.cc @@ -83,6 +83,15 @@ ConsumerProcurementServiceAuth::ListOrders( return child_->ListOrders(context, options, request); } +StatusOr +ConsumerProcurementServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + future> ConsumerProcurementServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_auth_decorator.h b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_auth_decorator.h index 8a6a6095de10b..47da4d1b20d5e 100644 --- a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_auth_decorator.h +++ b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_auth_decorator.h @@ -63,6 +63,10 @@ class ConsumerProcurementServiceAuth : public ConsumerProcurementServiceStub { google::cloud::commerce::consumer::procurement::v1:: ListOrdersRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_connection_impl.cc b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_connection_impl.cc index 444630c29aad0..a8f15a4f27f20 100644 --- a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_connection_impl.cc +++ b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_connection_impl.cc @@ -230,6 +230,20 @@ ConsumerProcurementServiceConnectionImpl::ListOrders( }); } +StatusOr +ConsumerProcurementServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace commerce_consumer_procurement_v1_internal } // namespace cloud diff --git a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_connection_impl.h b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_connection_impl.h index eab8fa1761507..ba1d3584d5e0d 100644 --- a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_connection_impl.h +++ b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_connection_impl.h @@ -76,6 +76,9 @@ class ConsumerProcurementServiceConnectionImpl google::cloud::commerce::consumer::procurement::v1::ListOrdersRequest request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr< diff --git a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_logging_decorator.cc b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_logging_decorator.cc index fa78ab22d6a08..234d022e7e763 100644 --- a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_logging_decorator.cc +++ b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_logging_decorator.cc @@ -98,6 +98,18 @@ ConsumerProcurementServiceLogging::ListOrders( context, options, request, __func__, tracing_options_); } +StatusOr +ConsumerProcurementServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> ConsumerProcurementServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_logging_decorator.h b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_logging_decorator.h index f68c556c09b0b..274157898eb8d 100644 --- a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_logging_decorator.h +++ b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_logging_decorator.h @@ -64,6 +64,10 @@ class ConsumerProcurementServiceLogging google::cloud::commerce::consumer::procurement::v1:: ListOrdersRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_metadata_decorator.cc b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_metadata_decorator.cc index c835deeb0c8ae..d599a38d3816a 100644 --- a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_metadata_decorator.cc +++ b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_metadata_decorator.cc @@ -88,6 +88,15 @@ ConsumerProcurementServiceMetadata::ListOrders( return child_->ListOrders(context, options, request); } +StatusOr +ConsumerProcurementServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + future> ConsumerProcurementServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_metadata_decorator.h b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_metadata_decorator.h index 9391806d8d262..5f32f3f366eba 100644 --- a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_metadata_decorator.h +++ b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_metadata_decorator.h @@ -65,6 +65,10 @@ class ConsumerProcurementServiceMetadata google::cloud::commerce::consumer::procurement::v1:: ListOrdersRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_stub.cc b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_stub.cc index 4bd8950c29a2a..8230e04f7615d 100644 --- a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_stub.cc +++ b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_stub.cc @@ -92,6 +92,18 @@ DefaultConsumerProcurementServiceStub::ListOrders( return response; } +StatusOr +DefaultConsumerProcurementServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultConsumerProcurementServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_stub.h b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_stub.h index afb3c24cb2d94..818f2436e977e 100644 --- a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_stub.h +++ b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_stub.h @@ -63,6 +63,10 @@ class ConsumerProcurementServiceStub { google::cloud::commerce::consumer::procurement::v1:: ListOrdersRequest const& request) = 0; + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -83,9 +87,13 @@ class DefaultConsumerProcurementServiceStub std::unique_ptr grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} future> AsyncPlaceOrder( google::cloud::CompletionQueue& cq, @@ -110,6 +118,10 @@ class DefaultConsumerProcurementServiceStub google::cloud::commerce::consumer::procurement::v1:: ListOrdersRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -126,6 +138,8 @@ class DefaultConsumerProcurementServiceStub std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_stub_factory.cc b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_stub_factory.cc index 33af2150b9dd2..5de920afb4fac 100644 --- a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_stub_factory.cc +++ b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_stub_factory.cc @@ -30,6 +30,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -46,9 +47,11 @@ CreateDefaultConsumerProcurementServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::commerce::consumer::procurement::v1:: ConsumerProcurementService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_tracing_connection.cc b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_tracing_connection.cc index 037b0e1717e64..0fbfcd2dbad23 100644 --- a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_tracing_connection.cc +++ b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_tracing_connection.cc @@ -95,6 +95,16 @@ ConsumerProcurementServiceTracingConnection::ListOrders( std::move(span), std::move(sr)); } +StatusOr +ConsumerProcurementServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "commerce_consumer_procurement_v1::ConsumerProcurementServiceConnection::" + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr< diff --git a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_tracing_connection.h b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_tracing_connection.h index 8da6d80835882..cb024878504dc 100644 --- a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_tracing_connection.h +++ b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_tracing_connection.h @@ -64,6 +64,9 @@ class ConsumerProcurementServiceTracingConnection google::cloud::commerce::consumer::procurement::v1::ListOrdersRequest request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr< commerce_consumer_procurement_v1::ConsumerProcurementServiceConnection> diff --git a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_tracing_stub.cc b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_tracing_stub.cc index 212f80b6e266c..7c6be688544e2 100644 --- a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_tracing_stub.cc +++ b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_tracing_stub.cc @@ -95,6 +95,20 @@ ConsumerProcurementServiceTracingStub::ListOrders( child_->ListOrders(context, options, request)); } +StatusOr +ConsumerProcurementServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.commerce.consumer.procurement.v1." + "ConsumerProcurementService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + future> ConsumerProcurementServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_tracing_stub.h b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_tracing_stub.h index c71cf44d56c2d..784816a4194eb 100644 --- a/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_tracing_stub.h +++ b/google/cloud/commerce/consumer/procurement/v1/internal/consumer_procurement_tracing_stub.h @@ -64,6 +64,10 @@ class ConsumerProcurementServiceTracingStub google::cloud::commerce::consumer::procurement::v1:: ListOrdersRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/commerce/consumer/procurement/v1/mocks/mock_consumer_procurement_connection.h b/google/cloud/commerce/consumer/procurement/v1/mocks/mock_consumer_procurement_connection.h index 136c16dc9609b..ff704ada9e346 100644 --- a/google/cloud/commerce/consumer/procurement/v1/mocks/mock_consumer_procurement_connection.h +++ b/google/cloud/commerce/consumer/procurement/v1/mocks/mock_consumer_procurement_connection.h @@ -104,6 +104,10 @@ class MockConsumerProcurementServiceConnection (google::cloud::commerce::consumer::procurement::v1::ListOrdersRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/composer/v1/environments_client.cc b/google/cloud/composer/v1/environments_client.cc index 4ab420c3de6ee..180d5b3be4487 100644 --- a/google/cloud/composer/v1/environments_client.cc +++ b/google/cloud/composer/v1/environments_client.cc @@ -581,6 +581,49 @@ EnvironmentsClient::FetchDatabaseProperties( return connection_->FetchDatabaseProperties(request); } +StreamRange EnvironmentsClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange EnvironmentsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr EnvironmentsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr EnvironmentsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status EnvironmentsClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status EnvironmentsClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace composer_v1 } // namespace cloud diff --git a/google/cloud/composer/v1/environments_client.h b/google/cloud/composer/v1/environments_client.h index 924d02f660adf..e25f61f822c6f 100644 --- a/google/cloud/composer/v1/environments_client.h +++ b/google/cloud/composer/v1/environments_client.h @@ -1741,6 +1741,213 @@ class EnvironmentsClient { FetchDatabasePropertiesRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/composer/v1/environments_connection.cc b/google/cloud/composer/v1/environments_connection.cc index 9388348c0f9a4..b43a1a793eaf7 100644 --- a/google/cloud/composer/v1/environments_connection.cc +++ b/google/cloud/composer/v1/environments_connection.cc @@ -339,6 +339,24 @@ EnvironmentsConnection::FetchDatabaseProperties( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +EnvironmentsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr EnvironmentsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status EnvironmentsConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeEnvironmentsConnection( Options options) { internal::CheckExpectedOptions FetchDatabaseProperties(google::cloud::orchestration::airflow::service::v1:: FetchDatabasePropertiesRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); }; /** diff --git a/google/cloud/composer/v1/environments_connection_idempotency_policy.cc b/google/cloud/composer/v1/environments_connection_idempotency_policy.cc index 40fbaf8dee866..2b9078af01e8e 100644 --- a/google/cloud/composer/v1/environments_connection_idempotency_policy.cc +++ b/google/cloud/composer/v1/environments_connection_idempotency_policy.cc @@ -176,6 +176,21 @@ Idempotency EnvironmentsConnectionIdempotencyPolicy::FetchDatabaseProperties( return Idempotency::kIdempotent; } +Idempotency EnvironmentsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency EnvironmentsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency EnvironmentsConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultEnvironmentsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/composer/v1/environments_connection_idempotency_policy.h b/google/cloud/composer/v1/environments_connection_idempotency_policy.h index 3162dc0d45616..57414bded2011 100644 --- a/google/cloud/composer/v1/environments_connection_idempotency_policy.h +++ b/google/cloud/composer/v1/environments_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -128,6 +129,15 @@ class EnvironmentsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency FetchDatabaseProperties( google::cloud::orchestration::airflow::service::v1:: FetchDatabasePropertiesRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/composer/v1/image_versions_client.cc b/google/cloud/composer/v1/image_versions_client.cc index e4aa7b61646c0..8f7e67f35eb38 100644 --- a/google/cloud/composer/v1/image_versions_client.cc +++ b/google/cloud/composer/v1/image_versions_client.cc @@ -51,6 +51,49 @@ ImageVersionsClient::ListImageVersions( return connection_->ListImageVersions(std::move(request)); } +StreamRange ImageVersionsClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange ImageVersionsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr ImageVersionsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr ImageVersionsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status ImageVersionsClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status ImageVersionsClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace composer_v1 } // namespace cloud diff --git a/google/cloud/composer/v1/image_versions_client.h b/google/cloud/composer/v1/image_versions_client.h index 073319d5ab4c6..7be750b4d22ac 100644 --- a/google/cloud/composer/v1/image_versions_client.h +++ b/google/cloud/composer/v1/image_versions_client.h @@ -161,6 +161,213 @@ class ImageVersionsClient { ListImageVersionsRequest request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/composer/v1/image_versions_connection.cc b/google/cloud/composer/v1/image_versions_connection.cc index 5a0e183410a96..8bb11001d7462 100644 --- a/google/cloud/composer/v1/image_versions_connection.cc +++ b/google/cloud/composer/v1/image_versions_connection.cc @@ -46,6 +46,24 @@ ImageVersionsConnection::ListImageVersions( google::cloud::orchestration::airflow::service::v1::ImageVersion>>(); } +StreamRange +ImageVersionsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr ImageVersionsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ImageVersionsConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeImageVersionsConnection( Options options) { internal::CheckExpectedOptions ListImageVersions(google::cloud::orchestration::airflow::service::v1:: ListImageVersionsRequest request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); }; /** diff --git a/google/cloud/composer/v1/image_versions_connection_idempotency_policy.cc b/google/cloud/composer/v1/image_versions_connection_idempotency_policy.cc index 8db896dcfa982..da3add7ce35a7 100644 --- a/google/cloud/composer/v1/image_versions_connection_idempotency_policy.cc +++ b/google/cloud/composer/v1/image_versions_connection_idempotency_policy.cc @@ -40,6 +40,21 @@ Idempotency ImageVersionsConnectionIdempotencyPolicy::ListImageVersions( return Idempotency::kIdempotent; } +Idempotency ImageVersionsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ImageVersionsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ImageVersionsConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultImageVersionsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/composer/v1/image_versions_connection_idempotency_policy.h b/google/cloud/composer/v1/image_versions_connection_idempotency_policy.h index 4df44e1b56227..0a29d323989e6 100644 --- a/google/cloud/composer/v1/image_versions_connection_idempotency_policy.h +++ b/google/cloud/composer/v1/image_versions_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -40,6 +41,15 @@ class ImageVersionsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListImageVersions( google::cloud::orchestration::airflow::service::v1:: ListImageVersionsRequest request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/composer/v1/internal/environments_auth_decorator.cc b/google/cloud/composer/v1/internal/environments_auth_decorator.cc index 7fd2dbafa272e..a53d40eb8fe82 100644 --- a/google/cloud/composer/v1/internal/environments_auth_decorator.cc +++ b/google/cloud/composer/v1/internal/environments_auth_decorator.cc @@ -393,6 +393,31 @@ EnvironmentsAuth::FetchDatabaseProperties( return child_->FetchDatabaseProperties(context, options, request); } +StatusOr +EnvironmentsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr EnvironmentsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status EnvironmentsAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + future> EnvironmentsAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/composer/v1/internal/environments_auth_decorator.h b/google/cloud/composer/v1/internal/environments_auth_decorator.h index 7054096a00266..ab0d963815d0f 100644 --- a/google/cloud/composer/v1/internal/environments_auth_decorator.h +++ b/google/cloud/composer/v1/internal/environments_auth_decorator.h @@ -220,6 +220,18 @@ class EnvironmentsAuth : public EnvironmentsStub { google::cloud::orchestration::airflow::service::v1:: FetchDatabasePropertiesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/composer/v1/internal/environments_connection_impl.cc b/google/cloud/composer/v1/internal/environments_connection_impl.cc index cd03d5d66939d..41c5b982e8cb8 100644 --- a/google/cloud/composer/v1/internal/environments_connection_impl.cc +++ b/google/cloud/composer/v1/internal/environments_connection_impl.cc @@ -1027,6 +1027,66 @@ EnvironmentsConnectionImpl::FetchDatabaseProperties( *current, request, __func__); } +StreamRange +EnvironmentsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +EnvironmentsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status EnvironmentsConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace composer_v1_internal } // namespace cloud diff --git a/google/cloud/composer/v1/internal/environments_connection_impl.h b/google/cloud/composer/v1/internal/environments_connection_impl.h index 36f4aebcef5fb..c8bf8421590cf 100644 --- a/google/cloud/composer/v1/internal/environments_connection_impl.h +++ b/google/cloud/composer/v1/internal/environments_connection_impl.h @@ -221,6 +221,15 @@ class EnvironmentsConnectionImpl : public composer_v1::EnvironmentsConnection { google::cloud::orchestration::airflow::service::v1:: FetchDatabasePropertiesRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/composer/v1/internal/environments_logging_decorator.cc b/google/cloud/composer/v1/internal/environments_logging_decorator.cc index 8442e506f5786..58bff6152bca3 100644 --- a/google/cloud/composer/v1/internal/environments_logging_decorator.cc +++ b/google/cloud/composer/v1/internal/environments_logging_decorator.cc @@ -483,6 +483,40 @@ EnvironmentsLogging::FetchDatabaseProperties( context, options, request, __func__, tracing_options_); } +StatusOr +EnvironmentsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr EnvironmentsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status EnvironmentsLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> EnvironmentsLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/composer/v1/internal/environments_logging_decorator.h b/google/cloud/composer/v1/internal/environments_logging_decorator.h index 9e7f7ef137116..90d22c7356e9c 100644 --- a/google/cloud/composer/v1/internal/environments_logging_decorator.h +++ b/google/cloud/composer/v1/internal/environments_logging_decorator.h @@ -220,6 +220,18 @@ class EnvironmentsLogging : public EnvironmentsStub { google::cloud::orchestration::airflow::service::v1:: FetchDatabasePropertiesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/composer/v1/internal/environments_metadata_decorator.cc b/google/cloud/composer/v1/internal/environments_metadata_decorator.cc index 192cad4b8cbb7..081a3033a88ea 100644 --- a/google/cloud/composer/v1/internal/environments_metadata_decorator.cc +++ b/google/cloud/composer/v1/internal/environments_metadata_decorator.cc @@ -375,6 +375,31 @@ EnvironmentsMetadata::FetchDatabaseProperties( return child_->FetchDatabaseProperties(context, options, request); } +StatusOr +EnvironmentsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr EnvironmentsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status EnvironmentsMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + future> EnvironmentsMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/composer/v1/internal/environments_metadata_decorator.h b/google/cloud/composer/v1/internal/environments_metadata_decorator.h index 39b42fe312749..2eda5734e3cb4 100644 --- a/google/cloud/composer/v1/internal/environments_metadata_decorator.h +++ b/google/cloud/composer/v1/internal/environments_metadata_decorator.h @@ -220,6 +220,18 @@ class EnvironmentsMetadata : public EnvironmentsStub { google::cloud::orchestration::airflow::service::v1:: FetchDatabasePropertiesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/composer/v1/internal/environments_stub.cc b/google/cloud/composer/v1/internal/environments_stub.cc index 9de10e983adbb..77d25cfeb57fe 100644 --- a/google/cloud/composer/v1/internal/environments_stub.cc +++ b/google/cloud/composer/v1/internal/environments_stub.cc @@ -485,6 +485,40 @@ DefaultEnvironmentsStub::FetchDatabaseProperties( return response; } +StatusOr +DefaultEnvironmentsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultEnvironmentsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultEnvironmentsStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + future> DefaultEnvironmentsStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/composer/v1/internal/environments_stub.h b/google/cloud/composer/v1/internal/environments_stub.h index 1f587a6a9c8d2..80fc540863d6a 100644 --- a/google/cloud/composer/v1/internal/environments_stub.h +++ b/google/cloud/composer/v1/internal/environments_stub.h @@ -219,6 +219,18 @@ class EnvironmentsStub { google::cloud::orchestration::airflow::service::v1:: FetchDatabasePropertiesRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -238,9 +250,13 @@ class DefaultEnvironmentsStub : public EnvironmentsStub { std::unique_ptr grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateEnvironment( google::cloud::CompletionQueue& cq, @@ -423,6 +439,18 @@ class DefaultEnvironmentsStub : public EnvironmentsStub { google::cloud::orchestration::airflow::service::v1:: FetchDatabasePropertiesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -439,6 +467,8 @@ class DefaultEnvironmentsStub : public EnvironmentsStub { std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/composer/v1/internal/environments_stub_factory.cc b/google/cloud/composer/v1/internal/environments_stub_factory.cc index e4cc3eac13843..a035a895f3386 100644 --- a/google/cloud/composer/v1/internal/environments_stub_factory.cc +++ b/google/cloud/composer/v1/internal/environments_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 CreateDefaultEnvironmentsStub( auto service_grpc_stub = google::cloud::orchestration::airflow::service::v1::Environments::NewStub( channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/composer/v1/internal/environments_tracing_connection.cc b/google/cloud/composer/v1/internal/environments_tracing_connection.cc index 5fe7646f8e08a..ad1ed26df1878 100644 --- a/google/cloud/composer/v1/internal/environments_tracing_connection.cc +++ b/google/cloud/composer/v1/internal/environments_tracing_connection.cc @@ -424,6 +424,34 @@ EnvironmentsTracingConnection::FetchDatabaseProperties( return internal::EndSpan(*span, child_->FetchDatabaseProperties(request)); } +StreamRange +EnvironmentsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("composer_v1::EnvironmentsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +EnvironmentsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("composer_v1::EnvironmentsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status EnvironmentsTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "composer_v1::EnvironmentsConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/composer/v1/internal/environments_tracing_connection.h b/google/cloud/composer/v1/internal/environments_tracing_connection.h index daaf8349cc99a..34bbac0dfe85f 100644 --- a/google/cloud/composer/v1/internal/environments_tracing_connection.h +++ b/google/cloud/composer/v1/internal/environments_tracing_connection.h @@ -210,6 +210,15 @@ class EnvironmentsTracingConnection google::cloud::orchestration::airflow::service::v1:: FetchDatabasePropertiesRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/composer/v1/internal/environments_tracing_stub.cc b/google/cloud/composer/v1/internal/environments_tracing_stub.cc index 7b51e94aa7cdf..e246b2c92348e 100644 --- a/google/cloud/composer/v1/internal/environments_tracing_stub.cc +++ b/google/cloud/composer/v1/internal/environments_tracing_stub.cc @@ -475,6 +475,43 @@ EnvironmentsTracingStub::FetchDatabaseProperties( child_->FetchDatabaseProperties(context, options, request)); } +StatusOr +EnvironmentsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.orchestration.airflow.service.v1.Environments", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr EnvironmentsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.orchestration.airflow.service.v1.Environments", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status EnvironmentsTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.orchestration.airflow.service.v1.Environments", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + future> EnvironmentsTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/composer/v1/internal/environments_tracing_stub.h b/google/cloud/composer/v1/internal/environments_tracing_stub.h index 4001a80de4473..d43b80a82d8fc 100644 --- a/google/cloud/composer/v1/internal/environments_tracing_stub.h +++ b/google/cloud/composer/v1/internal/environments_tracing_stub.h @@ -219,6 +219,18 @@ class EnvironmentsTracingStub : public EnvironmentsStub { google::cloud::orchestration::airflow::service::v1:: FetchDatabasePropertiesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/composer/v1/internal/image_versions_auth_decorator.cc b/google/cloud/composer/v1/internal/image_versions_auth_decorator.cc index e7dcfdd52cb33..ce5812957630f 100644 --- a/google/cloud/composer/v1/internal/image_versions_auth_decorator.cc +++ b/google/cloud/composer/v1/internal/image_versions_auth_decorator.cc @@ -42,6 +42,31 @@ ImageVersionsAuth::ListImageVersions( return child_->ListImageVersions(context, options, request); } +StatusOr +ImageVersionsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr ImageVersionsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status ImageVersionsAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace composer_v1_internal } // namespace cloud diff --git a/google/cloud/composer/v1/internal/image_versions_auth_decorator.h b/google/cloud/composer/v1/internal/image_versions_auth_decorator.h index e4a37f53f9743..eac4ee7a52ff4 100644 --- a/google/cloud/composer/v1/internal/image_versions_auth_decorator.h +++ b/google/cloud/composer/v1/internal/image_versions_auth_decorator.h @@ -44,6 +44,18 @@ class ImageVersionsAuth : public ImageVersionsStub { google::cloud::orchestration::airflow::service::v1:: ListImageVersionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/composer/v1/internal/image_versions_connection_impl.cc b/google/cloud/composer/v1/internal/image_versions_connection_impl.cc index 0606e99ed2397..0f619e52529ac 100644 --- a/google/cloud/composer/v1/internal/image_versions_connection_impl.cc +++ b/google/cloud/composer/v1/internal/image_versions_connection_impl.cc @@ -97,6 +97,66 @@ ImageVersionsConnectionImpl::ListImageVersions( }); } +StreamRange +ImageVersionsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ImageVersionsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ImageVersionsConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace composer_v1_internal } // namespace cloud diff --git a/google/cloud/composer/v1/internal/image_versions_connection_impl.h b/google/cloud/composer/v1/internal/image_versions_connection_impl.h index e079d58b8408c..dd9c0f52f7e0b 100644 --- a/google/cloud/composer/v1/internal/image_versions_connection_impl.h +++ b/google/cloud/composer/v1/internal/image_versions_connection_impl.h @@ -53,6 +53,15 @@ class ImageVersionsConnectionImpl ListImageVersions(google::cloud::orchestration::airflow::service::v1:: ListImageVersionsRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/composer/v1/internal/image_versions_logging_decorator.cc b/google/cloud/composer/v1/internal/image_versions_logging_decorator.cc index c5e71f63d6bff..8f09a5ab1c34a 100644 --- a/google/cloud/composer/v1/internal/image_versions_logging_decorator.cc +++ b/google/cloud/composer/v1/internal/image_versions_logging_decorator.cc @@ -50,6 +50,40 @@ ImageVersionsLogging::ListImageVersions( context, options, request, __func__, tracing_options_); } +StatusOr +ImageVersionsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ImageVersionsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ImageVersionsLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace composer_v1_internal } // namespace cloud diff --git a/google/cloud/composer/v1/internal/image_versions_logging_decorator.h b/google/cloud/composer/v1/internal/image_versions_logging_decorator.h index 745f77f1a432d..36a3e04bde0ff 100644 --- a/google/cloud/composer/v1/internal/image_versions_logging_decorator.h +++ b/google/cloud/composer/v1/internal/image_versions_logging_decorator.h @@ -44,6 +44,18 @@ class ImageVersionsLogging : public ImageVersionsStub { google::cloud::orchestration::airflow::service::v1:: ListImageVersionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/composer/v1/internal/image_versions_metadata_decorator.cc b/google/cloud/composer/v1/internal/image_versions_metadata_decorator.cc index 538168452f784..f8154d23d6c9c 100644 --- a/google/cloud/composer/v1/internal/image_versions_metadata_decorator.cc +++ b/google/cloud/composer/v1/internal/image_versions_metadata_decorator.cc @@ -55,6 +55,31 @@ ImageVersionsMetadata::ListImageVersions( return child_->ListImageVersions(context, options, request); } +StatusOr +ImageVersionsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr ImageVersionsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status ImageVersionsMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + void ImageVersionsMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/composer/v1/internal/image_versions_metadata_decorator.h b/google/cloud/composer/v1/internal/image_versions_metadata_decorator.h index 7b216b63a8c9c..515721d280981 100644 --- a/google/cloud/composer/v1/internal/image_versions_metadata_decorator.h +++ b/google/cloud/composer/v1/internal/image_versions_metadata_decorator.h @@ -44,6 +44,18 @@ class ImageVersionsMetadata : public ImageVersionsStub { google::cloud::orchestration::airflow::service::v1:: ListImageVersionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/composer/v1/internal/image_versions_stub.cc b/google/cloud/composer/v1/internal/image_versions_stub.cc index fc75069e1a923..51bed33d3b5c9 100644 --- a/google/cloud/composer/v1/internal/image_versions_stub.cc +++ b/google/cloud/composer/v1/internal/image_versions_stub.cc @@ -45,6 +45,40 @@ DefaultImageVersionsStub::ListImageVersions( return response; } +StatusOr +DefaultImageVersionsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultImageVersionsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultImageVersionsStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace composer_v1_internal } // namespace cloud diff --git a/google/cloud/composer/v1/internal/image_versions_stub.h b/google/cloud/composer/v1/internal/image_versions_stub.h index 7a84a5026d3bf..223e1c941dc08 100644 --- a/google/cloud/composer/v1/internal/image_versions_stub.h +++ b/google/cloud/composer/v1/internal/image_versions_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -40,6 +41,18 @@ class ImageVersionsStub { ListImageVersions(grpc::ClientContext& context, Options const& options, google::cloud::orchestration::airflow::service::v1:: ListImageVersionsRequest const& request) = 0; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; }; class DefaultImageVersionsStub : public ImageVersionsStub { @@ -47,8 +60,11 @@ class DefaultImageVersionsStub : public ImageVersionsStub { explicit DefaultImageVersionsStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr @@ -56,10 +72,24 @@ class DefaultImageVersionsStub : public ImageVersionsStub { google::cloud::orchestration::airflow::service::v1:: ListImageVersionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/composer/v1/internal/image_versions_stub_factory.cc b/google/cloud/composer/v1/internal/image_versions_stub_factory.cc index a3adba07c50f5..ae10e6b4f1686 100644 --- a/google/cloud/composer/v1/internal/image_versions_stub_factory.cc +++ b/google/cloud/composer/v1/internal/image_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,11 @@ std::shared_ptr CreateDefaultImageVersionsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::orchestration::airflow::service::v1:: ImageVersions::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_stub)); if (auth->RequiresConfigureContext()) { stub = diff --git a/google/cloud/composer/v1/internal/image_versions_tracing_connection.cc b/google/cloud/composer/v1/internal/image_versions_tracing_connection.cc index 6f298620a1d17..0504b56bb9c47 100644 --- a/google/cloud/composer/v1/internal/image_versions_tracing_connection.cc +++ b/google/cloud/composer/v1/internal/image_versions_tracing_connection.cc @@ -46,6 +46,34 @@ ImageVersionsTracingConnection::ListImageVersions( std::move(span), std::move(sr)); } +StreamRange +ImageVersionsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "composer_v1::ImageVersionsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ImageVersionsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("composer_v1::ImageVersionsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status ImageVersionsTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "composer_v1::ImageVersionsConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/composer/v1/internal/image_versions_tracing_connection.h b/google/cloud/composer/v1/internal/image_versions_tracing_connection.h index 580cb30e6eeef..7d9ba32e726fa 100644 --- a/google/cloud/composer/v1/internal/image_versions_tracing_connection.h +++ b/google/cloud/composer/v1/internal/image_versions_tracing_connection.h @@ -44,6 +44,15 @@ class ImageVersionsTracingConnection ListImageVersions(google::cloud::orchestration::airflow::service::v1:: ListImageVersionsRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/composer/v1/internal/image_versions_tracing_stub.cc b/google/cloud/composer/v1/internal/image_versions_tracing_stub.cc index ba1420bca4455..38a13f6c82d31 100644 --- a/google/cloud/composer/v1/internal/image_versions_tracing_stub.cc +++ b/google/cloud/composer/v1/internal/image_versions_tracing_stub.cc @@ -47,6 +47,43 @@ ImageVersionsTracingStub::ListImageVersions( context, *span, child_->ListImageVersions(context, options, request)); } +StatusOr +ImageVersionsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.orchestration.airflow.service.v1.ImageVersions", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr ImageVersionsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.orchestration.airflow.service.v1.ImageVersions", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status ImageVersionsTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.orchestration.airflow.service.v1.ImageVersions", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeImageVersionsTracingStub( diff --git a/google/cloud/composer/v1/internal/image_versions_tracing_stub.h b/google/cloud/composer/v1/internal/image_versions_tracing_stub.h index 72cb2e9fb6171..4a9247bf952d4 100644 --- a/google/cloud/composer/v1/internal/image_versions_tracing_stub.h +++ b/google/cloud/composer/v1/internal/image_versions_tracing_stub.h @@ -44,6 +44,18 @@ class ImageVersionsTracingStub : public ImageVersionsStub { google::cloud::orchestration::airflow::service::v1:: ListImageVersionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/composer/v1/mocks/mock_environments_connection.h b/google/cloud/composer/v1/mocks/mock_environments_connection.h index 572718dab5ea7..6020f532164c3 100644 --- a/google/cloud/composer/v1/mocks/mock_environments_connection.h +++ b/google/cloud/composer/v1/mocks/mock_environments_connection.h @@ -406,6 +406,17 @@ class MockEnvironmentsConnection : public composer_v1::EnvironmentsConnection { (google::cloud::orchestration::airflow::service::v1:: FetchDatabasePropertiesRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/composer/v1/mocks/mock_image_versions_connection.h b/google/cloud/composer/v1/mocks/mock_image_versions_connection.h index cb2d0b0e62680..3e103e6a3d81b 100644 --- a/google/cloud/composer/v1/mocks/mock_image_versions_connection.h +++ b/google/cloud/composer/v1/mocks/mock_image_versions_connection.h @@ -54,6 +54,17 @@ class MockImageVersionsConnection (google::cloud::orchestration::airflow::service::v1:: ListImageVersionsRequest request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END 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 @@ -198,6 +199,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..334d9b88e43b8 100644 --- a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_stub.h +++ b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -47,6 +48,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 +64,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 +81,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..60ba57198b0fe 100644 --- a/google/cloud/config/v1/config_client.cc +++ b/google/cloud/config/v1/config_client.cc @@ -541,6 +541,92 @@ 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); +} + +StreamRange ConfigClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange ConfigClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr ConfigClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr ConfigClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status ConfigClient::DeleteOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status ConfigClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status ConfigClient::CancelOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status ConfigClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..2041e2154d07e 100644 --- a/google/cloud/config/v1/config_client.h +++ b/google/cloud/config/v1/config_client.h @@ -1841,6 +1841,458 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..1d36c170cfb7d 100644 --- a/google/cloud/config/v1/config_connection.cc +++ b/google/cloud/config/v1/config_connection.cc @@ -284,6 +284,56 @@ 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"); +} + +StreamRange ConfigConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr ConfigConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ConfigConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ConfigConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeConfigConnection(Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..e014bba25902c 100644 --- a/google/cloud/config/v1/config_connection_idempotency_policy.cc +++ b/google/cloud/config/v1/config_connection_idempotency_policy.cc @@ -149,6 +149,52 @@ 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; +} + +Idempotency ConfigConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ConfigConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ConfigConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency ConfigConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..f30b6cef45f02 100644 --- a/google/cloud/config/v1/config_connection_idempotency_policy.h +++ b/google/cloud/config/v1/config_connection_idempotency_policy.h @@ -22,6 +22,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -105,6 +108,33 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..2d838026d1c3b 100644 --- a/google/cloud/config/v1/internal/config_auth_decorator.cc +++ b/google/cloud/config/v1/internal/config_auth_decorator.cc @@ -363,6 +363,81 @@ 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); +} + +StatusOr +ConfigAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr ConfigAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status ConfigAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status ConfigAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..bf39968eec3b8 100644 --- a/google/cloud/config/v1/internal/config_auth_decorator.h +++ b/google/cloud/config/v1/internal/config_auth_decorator.h @@ -191,6 +191,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..9e52579116bb4 100644 --- a/google/cloud/config/v1/internal/config_connection_impl.cc +++ b/google/cloud/config/v1/internal/config_connection_impl.cc @@ -1016,6 +1016,165 @@ 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__); +} + +StreamRange +ConfigConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr ConfigConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ConfigConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ConfigConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..5baed352ac7c1 100644 --- a/google/cloud/config/v1/internal/config_connection_impl.h +++ b/google/cloud/config/v1/internal/config_connection_impl.h @@ -184,6 +184,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..7ef21de962d85 100644 --- a/google/cloud/config/v1/internal/config_logging_decorator.cc +++ b/google/cloud/config/v1/internal/config_logging_decorator.cc @@ -437,6 +437,108 @@ 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_); +} + +StatusOr +ConfigLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ConfigLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ConfigLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ConfigLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..5156c6483d282 100644 --- a/google/cloud/config/v1/internal/config_logging_decorator.h +++ b/google/cloud/config/v1/internal/config_logging_decorator.h @@ -191,6 +191,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..eb201c3c99df7 100644 --- a/google/cloud/config/v1/internal/config_metadata_decorator.cc +++ b/google/cloud/config/v1/internal/config_metadata_decorator.cc @@ -324,6 +324,84 @@ 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); +} + +StatusOr +ConfigMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr ConfigMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status ConfigMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status ConfigMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..760800748e90e 100644 --- a/google/cloud/config/v1/internal/config_metadata_decorator.h +++ b/google/cloud/config/v1/internal/config_metadata_decorator.h @@ -191,6 +191,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..b7519ebd02b5c 100644 --- a/google/cloud/config/v1/internal/config_stub.cc +++ b/google/cloud/config/v1/internal/config_stub.cc @@ -424,6 +424,109 @@ 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; +} + +StatusOr +DefaultConfigStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultConfigStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultConfigStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultConfigStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..3d869112f8986 100644 --- a/google/cloud/config/v1/internal/config_stub.h +++ b/google/cloud/config/v1/internal/config_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -188,6 +190,44 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -206,9 +246,18 @@ class DefaultConfigStub : public ConfigStub { DefaultConfigStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +411,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -376,6 +461,11 @@ class DefaultConfigStub : public ConfigStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..902964f192724 100644 --- a/google/cloud/config/v1/internal/config_stub_factory.cc +++ b/google/cloud/config/v1/internal/config_stub_factory.cc @@ -29,6 +29,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -43,8 +46,14 @@ 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_operations_stub = + google::longrunning::Operations::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_operations_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..0e8ec93eccc41 100644 --- a/google/cloud/config/v1/internal/config_tracing_connection.cc +++ b/google/cloud/config/v1/internal/config_tracing_connection.cc @@ -374,6 +374,80 @@ 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)); +} + +StreamRange +ConfigTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan("config_v1::ConfigConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr ConfigTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan("config_v1::ConfigConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status ConfigTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = + internal::MakeSpan("config_v1::ConfigConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status ConfigTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("config_v1::ConfigConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..9d24783e614b9 100644 --- a/google/cloud/config/v1/internal/config_tracing_connection.h +++ b/google/cloud/config/v1/internal/config_tracing_connection.h @@ -173,6 +173,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..e61c9e5029dec 100644 --- a/google/cloud/config/v1/internal/config_tracing_stub.cc +++ b/google/cloud/config/v1/internal/config_tracing_stub.cc @@ -401,6 +401,108 @@ 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)); +} + +StatusOr +ConfigTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.config.v1.Config", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr ConfigTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.config.v1.Config", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status ConfigTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.config.v1.Config", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status ConfigTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.config.v1.Config", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..553ff3af80287 100644 --- a/google/cloud/config/v1/internal/config_tracing_stub.h +++ b/google/cloud/config/v1/internal/config_tracing_stub.h @@ -190,6 +190,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..8070887663c78 100644 --- a/google/cloud/config/v1/mocks/mock_config_connection.h +++ b/google/cloud/config/v1/mocks/mock_config_connection.h @@ -384,6 +384,42 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..55beb185622ab 100644 --- a/google/cloud/connectors/v1/connectors_client.cc +++ b/google/cloud/connectors/v1/connectors_client.cc @@ -419,6 +419,94 @@ 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); +} + +StreamRange ConnectorsClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange ConnectorsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr ConnectorsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr ConnectorsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status ConnectorsClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status ConnectorsClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status ConnectorsClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status ConnectorsClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..27ab26b34fa8e 100644 --- a/google/cloud/connectors/v1/connectors_client.h +++ b/google/cloud/connectors/v1/connectors_client.h @@ -1437,6 +1437,458 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..efd3d9dff700d 100644 --- a/google/cloud/connectors/v1/connectors_connection.cc +++ b/google/cloud/connectors/v1/connectors_connection.cc @@ -216,6 +216,58 @@ 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"); +} + +StreamRange +ConnectorsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr ConnectorsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ConnectorsConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ConnectorsConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeConnectorsConnection( Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..b40cb6f551597 100644 --- a/google/cloud/connectors/v1/connectors_connection_idempotency_policy.cc +++ b/google/cloud/connectors/v1/connectors_connection_idempotency_policy.cc @@ -121,6 +121,52 @@ 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; +} + +Idempotency ConnectorsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ConnectorsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ConnectorsConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency ConnectorsConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..4fcfcae0d9b51 100644 --- a/google/cloud/connectors/v1/connectors_connection_idempotency_policy.h +++ b/google/cloud/connectors/v1/connectors_connection_idempotency_policy.h @@ -22,6 +22,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -88,6 +91,33 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..8b38cad5eab73 100644 --- a/google/cloud/connectors/v1/internal/connectors_auth_decorator.cc +++ b/google/cloud/connectors/v1/internal/connectors_auth_decorator.cc @@ -265,6 +265,81 @@ 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); +} + +StatusOr +ConnectorsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr ConnectorsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status ConnectorsAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status ConnectorsAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..285c8f811d54a 100644 --- a/google/cloud/connectors/v1/internal/connectors_auth_decorator.h +++ b/google/cloud/connectors/v1/internal/connectors_auth_decorator.h @@ -157,6 +157,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..f47f3f77eb838 100644 --- a/google/cloud/connectors/v1/internal/connectors_connection_impl.cc +++ b/google/cloud/connectors/v1/internal/connectors_connection_impl.cc @@ -755,6 +755,166 @@ 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__); +} + +StreamRange +ConnectorsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr ConnectorsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ConnectorsConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ConnectorsConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..8c178d775acc4 100644 --- a/google/cloud/connectors/v1/internal/connectors_connection_impl.h +++ b/google/cloud/connectors/v1/internal/connectors_connection_impl.h @@ -154,6 +154,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..cd76a4cd522da 100644 --- a/google/cloud/connectors/v1/internal/connectors_logging_decorator.cc +++ b/google/cloud/connectors/v1/internal/connectors_logging_decorator.cc @@ -337,6 +337,108 @@ 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_); +} + +StatusOr +ConnectorsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ConnectorsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ConnectorsLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ConnectorsLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..326d43f60b982 100644 --- a/google/cloud/connectors/v1/internal/connectors_logging_decorator.h +++ b/google/cloud/connectors/v1/internal/connectors_logging_decorator.h @@ -157,6 +157,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..4e822977184b5 100644 --- a/google/cloud/connectors/v1/internal/connectors_metadata_decorator.cc +++ b/google/cloud/connectors/v1/internal/connectors_metadata_decorator.cc @@ -250,6 +250,84 @@ 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); +} + +StatusOr +ConnectorsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr ConnectorsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status ConnectorsMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status ConnectorsMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..9aa8b87ed10aa 100644 --- a/google/cloud/connectors/v1/internal/connectors_metadata_decorator.h +++ b/google/cloud/connectors/v1/internal/connectors_metadata_decorator.h @@ -157,6 +157,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..e95b9c596aaa3 100644 --- a/google/cloud/connectors/v1/internal/connectors_stub.cc +++ b/google/cloud/connectors/v1/internal/connectors_stub.cc @@ -322,6 +322,109 @@ 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; +} + +StatusOr +DefaultConnectorsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultConnectorsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultConnectorsStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultConnectorsStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..1679fead384ad 100644 --- a/google/cloud/connectors/v1/internal/connectors_stub.h +++ b/google/cloud/connectors/v1/internal/connectors_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -160,6 +162,44 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -178,9 +218,18 @@ class DefaultConnectorsStub : public ConnectorsStub { DefaultConnectorsStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +349,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -315,6 +400,11 @@ class DefaultConnectorsStub : public ConnectorsStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..09358fb3b8bef 100644 --- a/google/cloud/connectors/v1/internal/connectors_stub_factory.cc +++ b/google/cloud/connectors/v1/internal/connectors_stub_factory.cc @@ -29,6 +29,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultConnectorsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::connectors::v1::Connectors::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..dbd5230433b22 100644 --- a/google/cloud/connectors/v1/internal/connectors_tracing_connection.cc +++ b/google/cloud/connectors/v1/internal/connectors_tracing_connection.cc @@ -290,6 +290,87 @@ 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)); +} + +StreamRange +ConnectorsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("connectors_v1::ConnectorsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ConnectorsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("connectors_v1::ConnectorsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status ConnectorsTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "connectors_v1::ConnectorsConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status ConnectorsTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "connectors_v1::ConnectorsConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..493cc4b0cb4e0 100644 --- a/google/cloud/connectors/v1/internal/connectors_tracing_connection.h +++ b/google/cloud/connectors/v1/internal/connectors_tracing_connection.h @@ -142,6 +142,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..7dc6cdbe3d0e8 100644 --- a/google/cloud/connectors/v1/internal/connectors_tracing_stub.cc +++ b/google/cloud/connectors/v1/internal/connectors_tracing_stub.cc @@ -306,6 +306,108 @@ 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)); +} + +StatusOr +ConnectorsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.connectors.v1.Connectors", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr ConnectorsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.connectors.v1.Connectors", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status ConnectorsTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.connectors.v1.Connectors", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status ConnectorsTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.connectors.v1.Connectors", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..fcba16b4a69c3 100644 --- a/google/cloud/connectors/v1/internal/connectors_tracing_stub.h +++ b/google/cloud/connectors/v1/internal/connectors_tracing_stub.h @@ -156,6 +156,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..39e8fb864e4d2 100644 --- a/google/cloud/connectors/v1/mocks/mock_connectors_connection.h +++ b/google/cloud/connectors/v1/mocks/mock_connectors_connection.h @@ -277,6 +277,42 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/contactcenterinsights/v1/contact_center_insights_client.cc b/google/cloud/contactcenterinsights/v1/contact_center_insights_client.cc index 439ee63d78449..7815f5e30d1c2 100644 --- a/google/cloud/contactcenterinsights/v1/contact_center_insights_client.cc +++ b/google/cloud/contactcenterinsights/v1/contact_center_insights_client.cc @@ -1032,6 +1032,54 @@ Status ContactCenterInsightsClient::DeleteView( return connection_->DeleteView(request); } +StreamRange +ContactCenterInsightsClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +ContactCenterInsightsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +ContactCenterInsightsClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +ContactCenterInsightsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status ContactCenterInsightsClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status ContactCenterInsightsClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace contactcenterinsights_v1 } // namespace cloud diff --git a/google/cloud/contactcenterinsights/v1/contact_center_insights_client.h b/google/cloud/contactcenterinsights/v1/contact_center_insights_client.h index 1e0a83bfad777..e71748038c0e9 100644 --- a/google/cloud/contactcenterinsights/v1/contact_center_insights_client.h +++ b/google/cloud/contactcenterinsights/v1/contact_center_insights_client.h @@ -2991,6 +2991,231 @@ class ContactCenterInsightsClient { request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/contactcenterinsights/v1/contact_center_insights_connection.cc b/google/cloud/contactcenterinsights/v1/contact_center_insights_connection.cc index d63a5f4348ae7..b2eea3d2e3f27 100644 --- a/google/cloud/contactcenterinsights/v1/contact_center_insights_connection.cc +++ b/google/cloud/contactcenterinsights/v1/contact_center_insights_connection.cc @@ -487,6 +487,25 @@ Status ContactCenterInsightsConnection::DeleteView( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +ContactCenterInsightsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +ContactCenterInsightsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ContactCenterInsightsConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeContactCenterInsightsConnection(Options options) { internal::CheckExpectedOptions ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/contactcenterinsights/v1/contact_center_insights_connection_idempotency_policy.cc b/google/cloud/contactcenterinsights/v1/contact_center_insights_connection_idempotency_policy.cc index b93444c6e2ade..07be2b87e61e2 100644 --- a/google/cloud/contactcenterinsights/v1/contact_center_insights_connection_idempotency_policy.cc +++ b/google/cloud/contactcenterinsights/v1/contact_center_insights_connection_idempotency_policy.cc @@ -259,6 +259,21 @@ Idempotency ContactCenterInsightsConnectionIdempotencyPolicy::DeleteView( return Idempotency::kNonIdempotent; } +Idempotency ContactCenterInsightsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ContactCenterInsightsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ContactCenterInsightsConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultContactCenterInsightsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/contactcenterinsights/v1/contact_center_insights_connection_idempotency_policy.h b/google/cloud/contactcenterinsights/v1/contact_center_insights_connection_idempotency_policy.h index ad4187fdd6747..d34d298070dff 100644 --- a/google/cloud/contactcenterinsights/v1/contact_center_insights_connection_idempotency_policy.h +++ b/google/cloud/contactcenterinsights/v1/contact_center_insights_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -188,6 +189,15 @@ class ContactCenterInsightsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteView( google::cloud::contactcenterinsights::v1::DeleteViewRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_auth_decorator.cc b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_auth_decorator.cc index 04dc275cfbe69..675207a4ad2ca 100644 --- a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_auth_decorator.cc +++ b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_auth_decorator.cc @@ -624,6 +624,32 @@ Status ContactCenterInsightsAuth::DeleteView( return child_->DeleteView(context, options, request); } +StatusOr +ContactCenterInsightsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +ContactCenterInsightsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status ContactCenterInsightsAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + future> ContactCenterInsightsAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_auth_decorator.h b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_auth_decorator.h index 2b50c4a387539..396821ae5e4d4 100644 --- a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_auth_decorator.h +++ b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_auth_decorator.h @@ -317,6 +317,18 @@ class ContactCenterInsightsAuth : public ContactCenterInsightsStub { google::cloud::contactcenterinsights::v1::DeleteViewRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_connection_impl.cc b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_connection_impl.cc index e2127adf5d0c5..7e2e198ddb214 100644 --- a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_connection_impl.cc +++ b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_connection_impl.cc @@ -1589,6 +1589,67 @@ Status ContactCenterInsightsConnectionImpl::DeleteView( *current, request, __func__); } +StreamRange +ContactCenterInsightsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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< + contactcenterinsights_v1::ContactCenterInsightsRetryPolicy>( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ContactCenterInsightsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ContactCenterInsightsConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace contactcenterinsights_v1_internal } // namespace cloud diff --git a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_connection_impl.h b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_connection_impl.h index 031785494a695..4a6b8e34081ee 100644 --- a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_connection_impl.h +++ b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_connection_impl.h @@ -323,6 +323,15 @@ class ContactCenterInsightsConnectionImpl google::cloud::contactcenterinsights::v1::DeleteViewRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr diff --git a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_logging_decorator.cc b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_logging_decorator.cc index 3d441fe7fc9ff..5515f67843a2d 100644 --- a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_logging_decorator.cc +++ b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_logging_decorator.cc @@ -781,6 +781,41 @@ Status ContactCenterInsightsLogging::DeleteView( context, options, request, __func__, tracing_options_); } +StatusOr +ContactCenterInsightsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ContactCenterInsightsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ContactCenterInsightsLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> ContactCenterInsightsLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_logging_decorator.h b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_logging_decorator.h index b8534e2b97ba8..d7bfef007f352 100644 --- a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_logging_decorator.h +++ b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_logging_decorator.h @@ -317,6 +317,18 @@ class ContactCenterInsightsLogging : public ContactCenterInsightsStub { google::cloud::contactcenterinsights::v1::DeleteViewRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_metadata_decorator.cc b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_metadata_decorator.cc index 4a8e594a2e7bd..2f621efd4a029 100644 --- a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_metadata_decorator.cc +++ b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_metadata_decorator.cc @@ -566,6 +566,32 @@ Status ContactCenterInsightsMetadata::DeleteView( return child_->DeleteView(context, options, request); } +StatusOr +ContactCenterInsightsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +ContactCenterInsightsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status ContactCenterInsightsMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + future> ContactCenterInsightsMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_metadata_decorator.h b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_metadata_decorator.h index fa956d32c9c34..5245a41698d78 100644 --- a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_metadata_decorator.h +++ b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_metadata_decorator.h @@ -318,6 +318,18 @@ class ContactCenterInsightsMetadata : public ContactCenterInsightsStub { google::cloud::contactcenterinsights::v1::DeleteViewRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_stub.cc b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_stub.cc index acd0210edb648..201fe496f2156 100644 --- a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_stub.cc +++ b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_stub.cc @@ -736,6 +736,41 @@ Status DefaultContactCenterInsightsStub::DeleteView( return google::cloud::Status(); } +StatusOr +DefaultContactCenterInsightsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultContactCenterInsightsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultContactCenterInsightsStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + future> DefaultContactCenterInsightsStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_stub.h b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_stub.h index a20c31120c46c..d2292d85b9db3 100644 --- a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_stub.h +++ b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_stub.h @@ -332,6 +332,18 @@ class ContactCenterInsightsStub { google::cloud::contactcenterinsights::v1::DeleteViewRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -351,9 +363,13 @@ class DefaultContactCenterInsightsStub : public ContactCenterInsightsStub { std::unique_ptr grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr CreateConversation( @@ -633,6 +649,18 @@ class DefaultContactCenterInsightsStub : public ContactCenterInsightsStub { google::cloud::contactcenterinsights::v1::DeleteViewRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -649,6 +677,8 @@ class DefaultContactCenterInsightsStub : public ContactCenterInsightsStub { std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_stub_factory.cc b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_stub_factory.cc index f5976f198809b..9d6f73c4615b2 100644 --- a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_stub_factory.cc +++ b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_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 @@ CreateDefaultContactCenterInsightsStub( auto service_grpc_stub = google::cloud::contactcenterinsights::v1::ContactCenterInsights::NewStub( channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_tracing_connection.cc b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_tracing_connection.cc index 21454accff6aa..b81563cf27511 100644 --- a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_tracing_connection.cc +++ b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_tracing_connection.cc @@ -713,6 +713,37 @@ Status ContactCenterInsightsTracingConnection::DeleteView( return internal::EndSpan(*span, child_->DeleteView(request)); } +StreamRange +ContactCenterInsightsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "contactcenterinsights_v1::ContactCenterInsightsConnection::" + "ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ContactCenterInsightsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "contactcenterinsights_v1::ContactCenterInsightsConnection::" + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status ContactCenterInsightsTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "contactcenterinsights_v1::ContactCenterInsightsConnection::" + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_tracing_connection.h b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_tracing_connection.h index bde983165d4d1..65e1afa726505 100644 --- a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_tracing_connection.h +++ b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_tracing_connection.h @@ -310,6 +310,15 @@ class ContactCenterInsightsTracingConnection google::cloud::contactcenterinsights::v1::DeleteViewRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; diff --git a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_tracing_stub.cc b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_tracing_stub.cc index b1dab271c0326..21c08e913c209 100644 --- a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_tracing_stub.cc +++ b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_tracing_stub.cc @@ -743,6 +743,44 @@ Status ContactCenterInsightsTracingStub::DeleteView( child_->DeleteView(context, options, request)); } +StatusOr +ContactCenterInsightsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +ContactCenterInsightsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status ContactCenterInsightsTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + future> ContactCenterInsightsTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_tracing_stub.h b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_tracing_stub.h index 60901e3bb5f4a..05c47f49d8650 100644 --- a/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_tracing_stub.h +++ b/google/cloud/contactcenterinsights/v1/internal/contact_center_insights_tracing_stub.h @@ -317,6 +317,18 @@ class ContactCenterInsightsTracingStub : public ContactCenterInsightsStub { google::cloud::contactcenterinsights::v1::DeleteViewRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/contactcenterinsights/v1/mocks/mock_contact_center_insights_connection.h b/google/cloud/contactcenterinsights/v1/mocks/mock_contact_center_insights_connection.h index e35517f83d076..2a0a430e2b925 100644 --- a/google/cloud/contactcenterinsights/v1/mocks/mock_contact_center_insights_connection.h +++ b/google/cloud/contactcenterinsights/v1/mocks/mock_contact_center_insights_connection.h @@ -644,6 +644,17 @@ class MockContactCenterInsightsConnection (google::cloud::contactcenterinsights::v1::DeleteViewRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/contentwarehouse/v1/document_client.cc b/google/cloud/contentwarehouse/v1/document_client.cc index d96da7288df99..abddf4cd6b628 100644 --- a/google/cloud/contentwarehouse/v1/document_client.cc +++ b/google/cloud/contentwarehouse/v1/document_client.cc @@ -173,6 +173,20 @@ DocumentServiceClient::SetAcl( return connection_->SetAcl(request); } +StatusOr DocumentServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr DocumentServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace contentwarehouse_v1 } // namespace cloud diff --git a/google/cloud/contentwarehouse/v1/document_client.h b/google/cloud/contentwarehouse/v1/document_client.h index 58235b2f43447..70b78735d8181 100644 --- a/google/cloud/contentwarehouse/v1/document_client.h +++ b/google/cloud/contentwarehouse/v1/document_client.h @@ -614,6 +614,66 @@ class DocumentServiceClient { google::cloud::contentwarehouse::v1::SetAclRequest const& request, Options opts = {}); + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/contentwarehouse/v1/document_connection.cc b/google/cloud/contentwarehouse/v1/document_connection.cc index dbb725c9cee28..2b3f46f785648 100644 --- a/google/cloud/contentwarehouse/v1/document_connection.cc +++ b/google/cloud/contentwarehouse/v1/document_connection.cc @@ -89,6 +89,12 @@ DocumentServiceConnection::SetAcl( return Status(StatusCode::kUnimplemented, "not implemented"); } +StatusOr +DocumentServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDocumentServiceConnection( Options options) { internal::CheckExpectedOptions SetAcl( google::cloud::contentwarehouse::v1::SetAclRequest const& request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/contentwarehouse/v1/document_connection_idempotency_policy.cc b/google/cloud/contentwarehouse/v1/document_connection_idempotency_policy.cc index 64e88c80543d6..c9f819b6d2aee 100644 --- a/google/cloud/contentwarehouse/v1/document_connection_idempotency_policy.cc +++ b/google/cloud/contentwarehouse/v1/document_connection_idempotency_policy.cc @@ -74,6 +74,11 @@ Idempotency DocumentServiceConnectionIdempotencyPolicy::SetAcl( return Idempotency::kNonIdempotent; } +Idempotency DocumentServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultDocumentServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/contentwarehouse/v1/document_connection_idempotency_policy.h b/google/cloud/contentwarehouse/v1/document_connection_idempotency_policy.h index 98e29ba2b093c..4e26deb025356 100644 --- a/google/cloud/contentwarehouse/v1/document_connection_idempotency_policy.h +++ b/google/cloud/contentwarehouse/v1/document_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,9 @@ class DocumentServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency SetAcl( google::cloud::contentwarehouse::v1::SetAclRequest const& request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/contentwarehouse/v1/document_link_client.cc b/google/cloud/contentwarehouse/v1/document_link_client.cc index a26f0f43e2a03..667b6e6ee71ab 100644 --- a/google/cloud/contentwarehouse/v1/document_link_client.cc +++ b/google/cloud/contentwarehouse/v1/document_link_client.cc @@ -104,6 +104,21 @@ Status DocumentLinkServiceClient::DeleteDocumentLink( return connection_->DeleteDocumentLink(request); } +StatusOr +DocumentLinkServiceClient::GetOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +DocumentLinkServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace contentwarehouse_v1 } // namespace cloud diff --git a/google/cloud/contentwarehouse/v1/document_link_client.h b/google/cloud/contentwarehouse/v1/document_link_client.h index 37961ee4229c4..7642013b4f4bd 100644 --- a/google/cloud/contentwarehouse/v1/document_link_client.h +++ b/google/cloud/contentwarehouse/v1/document_link_client.h @@ -343,6 +343,66 @@ class DocumentLinkServiceClient { request, Options opts = {}); + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/contentwarehouse/v1/document_link_connection.cc b/google/cloud/contentwarehouse/v1/document_link_connection.cc index 58e6e82bdf771..4ba19d4fddb1c 100644 --- a/google/cloud/contentwarehouse/v1/document_link_connection.cc +++ b/google/cloud/contentwarehouse/v1/document_link_connection.cc @@ -63,6 +63,12 @@ Status DocumentLinkServiceConnection::DeleteDocumentLink( return Status(StatusCode::kUnimplemented, "not implemented"); } +StatusOr +DocumentLinkServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDocumentLinkServiceConnection(Options options) { internal::CheckExpectedOptions GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/contentwarehouse/v1/document_link_connection_idempotency_policy.cc b/google/cloud/contentwarehouse/v1/document_link_connection_idempotency_policy.cc index edbcd778b012d..4d21c06b7e3c3 100644 --- a/google/cloud/contentwarehouse/v1/document_link_connection_idempotency_policy.cc +++ b/google/cloud/contentwarehouse/v1/document_link_connection_idempotency_policy.cc @@ -55,6 +55,11 @@ Idempotency DocumentLinkServiceConnectionIdempotencyPolicy::DeleteDocumentLink( return Idempotency::kNonIdempotent; } +Idempotency DocumentLinkServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultDocumentLinkServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/contentwarehouse/v1/document_link_connection_idempotency_policy.h b/google/cloud/contentwarehouse/v1/document_link_connection_idempotency_policy.h index c4ea0575b1042..ba62e4baed9bf 100644 --- a/google/cloud/contentwarehouse/v1/document_link_connection_idempotency_policy.h +++ b/google/cloud/contentwarehouse/v1/document_link_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,9 @@ class DocumentLinkServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteDocumentLink( google::cloud::contentwarehouse::v1::DeleteDocumentLinkRequest const& request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/contentwarehouse/v1/document_schema_client.cc b/google/cloud/contentwarehouse/v1/document_schema_client.cc index dcdd1ad5a33aa..c7ab283093daf 100644 --- a/google/cloud/contentwarehouse/v1/document_schema_client.cc +++ b/google/cloud/contentwarehouse/v1/document_schema_client.cc @@ -125,6 +125,22 @@ DocumentSchemaServiceClient::ListDocumentSchemas( return connection_->ListDocumentSchemas(std::move(request)); } +StatusOr +DocumentSchemaServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +DocumentSchemaServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace contentwarehouse_v1 } // namespace cloud diff --git a/google/cloud/contentwarehouse/v1/document_schema_client.h b/google/cloud/contentwarehouse/v1/document_schema_client.h index 29293dbc9ae3e..f662c835c6f6a 100644 --- a/google/cloud/contentwarehouse/v1/document_schema_client.h +++ b/google/cloud/contentwarehouse/v1/document_schema_client.h @@ -420,6 +420,66 @@ class DocumentSchemaServiceClient { google::cloud::contentwarehouse::v1::ListDocumentSchemasRequest request, Options opts = {}); + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/contentwarehouse/v1/document_schema_connection.cc b/google/cloud/contentwarehouse/v1/document_schema_connection.cc index 1ab92c8e3b09e..efa2ceeb80909 100644 --- a/google/cloud/contentwarehouse/v1/document_schema_connection.cc +++ b/google/cloud/contentwarehouse/v1/document_schema_connection.cc @@ -69,6 +69,12 @@ DocumentSchemaServiceConnection::ListDocumentSchemas( StreamRange>(); } +StatusOr +DocumentSchemaServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDocumentSchemaServiceConnection(Options options) { internal::CheckExpectedOptions ListDocumentSchemas( google::cloud::contentwarehouse::v1::ListDocumentSchemasRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/contentwarehouse/v1/document_schema_connection_idempotency_policy.cc b/google/cloud/contentwarehouse/v1/document_schema_connection_idempotency_policy.cc index c0f2931ebab1f..6666237002bef 100644 --- a/google/cloud/contentwarehouse/v1/document_schema_connection_idempotency_policy.cc +++ b/google/cloud/contentwarehouse/v1/document_schema_connection_idempotency_policy.cc @@ -65,6 +65,11 @@ DocumentSchemaServiceConnectionIdempotencyPolicy::ListDocumentSchemas( return Idempotency::kIdempotent; } +Idempotency DocumentSchemaServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultDocumentSchemaServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/contentwarehouse/v1/document_schema_connection_idempotency_policy.h b/google/cloud/contentwarehouse/v1/document_schema_connection_idempotency_policy.h index efdfa5b0434a1..106a9fb21fcb7 100644 --- a/google/cloud/contentwarehouse/v1/document_schema_connection_idempotency_policy.h +++ b/google/cloud/contentwarehouse/v1/document_schema_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,9 @@ class DocumentSchemaServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListDocumentSchemas( google::cloud::contentwarehouse::v1::ListDocumentSchemasRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/contentwarehouse/v1/internal/document_auth_decorator.cc b/google/cloud/contentwarehouse/v1/internal/document_auth_decorator.cc index 795caae2219d9..bd096b6e74c46 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_auth_decorator.cc +++ b/google/cloud/contentwarehouse/v1/internal/document_auth_decorator.cc @@ -103,6 +103,14 @@ DocumentServiceAuth::SetAcl( return child_->SetAcl(context, options, request); } +StatusOr DocumentServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace contentwarehouse_v1_internal } // namespace cloud diff --git a/google/cloud/contentwarehouse/v1/internal/document_auth_decorator.h b/google/cloud/contentwarehouse/v1/internal/document_auth_decorator.h index 8c67645dc32da..074877a10a580 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_auth_decorator.h +++ b/google/cloud/contentwarehouse/v1/internal/document_auth_decorator.h @@ -81,6 +81,10 @@ class DocumentServiceAuth : public DocumentServiceStub { google::cloud::contentwarehouse::v1::SetAclRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/contentwarehouse/v1/internal/document_connection_impl.cc b/google/cloud/contentwarehouse/v1/internal/document_connection_impl.cc index 64eee53f9d64c..dff6db71e891d 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_connection_impl.cc +++ b/google/cloud/contentwarehouse/v1/internal/document_connection_impl.cc @@ -204,6 +204,20 @@ DocumentServiceConnectionImpl::SetAcl( *current, request, __func__); } +StatusOr +DocumentServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace contentwarehouse_v1_internal } // namespace cloud diff --git a/google/cloud/contentwarehouse/v1/internal/document_connection_impl.h b/google/cloud/contentwarehouse/v1/internal/document_connection_impl.h index 4acba93397c3b..d29002d0af457 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_connection_impl.h +++ b/google/cloud/contentwarehouse/v1/internal/document_connection_impl.h @@ -84,6 +84,9 @@ class DocumentServiceConnectionImpl google::cloud::contentwarehouse::v1::SetAclRequest const& request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/contentwarehouse/v1/internal/document_link_auth_decorator.cc b/google/cloud/contentwarehouse/v1/internal/document_link_auth_decorator.cc index 8765e039b5c63..7e007fb590c60 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_link_auth_decorator.cc +++ b/google/cloud/contentwarehouse/v1/internal/document_link_auth_decorator.cc @@ -70,6 +70,14 @@ Status DocumentLinkServiceAuth::DeleteDocumentLink( return child_->DeleteDocumentLink(context, options, request); } +StatusOr DocumentLinkServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace contentwarehouse_v1_internal } // namespace cloud diff --git a/google/cloud/contentwarehouse/v1/internal/document_link_auth_decorator.h b/google/cloud/contentwarehouse/v1/internal/document_link_auth_decorator.h index 6d28f30d4c338..c9398bf30ac30 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_link_auth_decorator.h +++ b/google/cloud/contentwarehouse/v1/internal/document_link_auth_decorator.h @@ -61,6 +61,10 @@ class DocumentLinkServiceAuth : public DocumentLinkServiceStub { google::cloud::contentwarehouse::v1::DeleteDocumentLinkRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/contentwarehouse/v1/internal/document_link_connection_impl.cc b/google/cloud/contentwarehouse/v1/internal/document_link_connection_impl.cc index c5f2c12510d5e..459c30ae02fe1 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_link_connection_impl.cc +++ b/google/cloud/contentwarehouse/v1/internal/document_link_connection_impl.cc @@ -151,6 +151,20 @@ Status DocumentLinkServiceConnectionImpl::DeleteDocumentLink( *current, request, __func__); } +StatusOr +DocumentLinkServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace contentwarehouse_v1_internal } // namespace cloud diff --git a/google/cloud/contentwarehouse/v1/internal/document_link_connection_impl.h b/google/cloud/contentwarehouse/v1/internal/document_link_connection_impl.h index ca919223c8f5c..63c9ca119fa9b 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_link_connection_impl.h +++ b/google/cloud/contentwarehouse/v1/internal/document_link_connection_impl.h @@ -69,6 +69,9 @@ class DocumentLinkServiceConnectionImpl google::cloud::contentwarehouse::v1::DeleteDocumentLinkRequest const& request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/contentwarehouse/v1/internal/document_link_logging_decorator.cc b/google/cloud/contentwarehouse/v1/internal/document_link_logging_decorator.cc index d7e03ad3654e0..c582ca2016a5a 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_link_logging_decorator.cc +++ b/google/cloud/contentwarehouse/v1/internal/document_link_logging_decorator.cc @@ -94,6 +94,18 @@ Status DocumentLinkServiceLogging::DeleteDocumentLink( context, options, request, __func__, tracing_options_); } +StatusOr +DocumentLinkServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace contentwarehouse_v1_internal } // namespace cloud diff --git a/google/cloud/contentwarehouse/v1/internal/document_link_logging_decorator.h b/google/cloud/contentwarehouse/v1/internal/document_link_logging_decorator.h index 714dae1d5afd7..376a542fd47db 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_link_logging_decorator.h +++ b/google/cloud/contentwarehouse/v1/internal/document_link_logging_decorator.h @@ -61,6 +61,10 @@ class DocumentLinkServiceLogging : public DocumentLinkServiceStub { google::cloud::contentwarehouse::v1::DeleteDocumentLinkRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/contentwarehouse/v1/internal/document_link_metadata_decorator.cc b/google/cloud/contentwarehouse/v1/internal/document_link_metadata_decorator.cc index 8664ba2c6b6c4..86f0fa2a3009f 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_link_metadata_decorator.cc +++ b/google/cloud/contentwarehouse/v1/internal/document_link_metadata_decorator.cc @@ -83,6 +83,15 @@ Status DocumentLinkServiceMetadata::DeleteDocumentLink( return child_->DeleteDocumentLink(context, options, request); } +StatusOr +DocumentLinkServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + void DocumentLinkServiceMetadata::SetMetadata( grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/contentwarehouse/v1/internal/document_link_metadata_decorator.h b/google/cloud/contentwarehouse/v1/internal/document_link_metadata_decorator.h index 144b45865cabb..1a555e0c07d19 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_link_metadata_decorator.h +++ b/google/cloud/contentwarehouse/v1/internal/document_link_metadata_decorator.h @@ -62,6 +62,10 @@ class DocumentLinkServiceMetadata : public DocumentLinkServiceStub { google::cloud::contentwarehouse::v1::DeleteDocumentLinkRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/contentwarehouse/v1/internal/document_link_stub.cc b/google/cloud/contentwarehouse/v1/internal/document_link_stub.cc index 7aa5c4a44efe5..6c35e145b4503 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_link_stub.cc +++ b/google/cloud/contentwarehouse/v1/internal/document_link_stub.cc @@ -81,6 +81,18 @@ Status DefaultDocumentLinkServiceStub::DeleteDocumentLink( return google::cloud::Status(); } +StatusOr +DefaultDocumentLinkServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace contentwarehouse_v1_internal } // namespace cloud diff --git a/google/cloud/contentwarehouse/v1/internal/document_link_stub.h b/google/cloud/contentwarehouse/v1/internal/document_link_stub.h index 2fb0b15f37e63..5caceb24f9083 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_link_stub.h +++ b/google/cloud/contentwarehouse/v1/internal/document_link_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -59,6 +60,10 @@ class DocumentLinkServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::contentwarehouse::v1::DeleteDocumentLinkRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; }; class DefaultDocumentLinkServiceStub : public DocumentLinkServiceStub { @@ -66,8 +71,11 @@ class DefaultDocumentLinkServiceStub : public DocumentLinkServiceStub { explicit DefaultDocumentLinkServiceStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr ListLinkedTargets( @@ -92,10 +100,16 @@ class DefaultDocumentLinkServiceStub : public DocumentLinkServiceStub { google::cloud::contentwarehouse::v1::DeleteDocumentLinkRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr< google::cloud::contentwarehouse::v1::DocumentLinkService::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/contentwarehouse/v1/internal/document_link_stub_factory.cc b/google/cloud/contentwarehouse/v1/internal/document_link_stub_factory.cc index afe7378939aeb..729a6b130042f 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_link_stub_factory.cc +++ b/google/cloud/contentwarehouse/v1/internal/document_link_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 CreateDefaultDocumentLinkServiceStub( auto service_grpc_stub = google::cloud::contentwarehouse::v1::DocumentLinkService::NewStub( channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_operations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/contentwarehouse/v1/internal/document_link_tracing_connection.cc b/google/cloud/contentwarehouse/v1/internal/document_link_tracing_connection.cc index d3898c5940d29..e1c6bdc1fb2dc 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_link_tracing_connection.cc +++ b/google/cloud/contentwarehouse/v1/internal/document_link_tracing_connection.cc @@ -74,6 +74,15 @@ Status DocumentLinkServiceTracingConnection::DeleteDocumentLink( return internal::EndSpan(*span, child_->DeleteDocumentLink(request)); } +StatusOr +DocumentLinkServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "contentwarehouse_v1::DocumentLinkServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/contentwarehouse/v1/internal/document_link_tracing_connection.h b/google/cloud/contentwarehouse/v1/internal/document_link_tracing_connection.h index b857041466337..b75a6924ac05d 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_link_tracing_connection.h +++ b/google/cloud/contentwarehouse/v1/internal/document_link_tracing_connection.h @@ -60,6 +60,9 @@ class DocumentLinkServiceTracingConnection google::cloud::contentwarehouse::v1::DeleteDocumentLinkRequest const& request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/contentwarehouse/v1/internal/document_link_tracing_stub.cc b/google/cloud/contentwarehouse/v1/internal/document_link_tracing_stub.cc index 8d28c17c65ba1..735a8e651cfef 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_link_tracing_stub.cc +++ b/google/cloud/contentwarehouse/v1/internal/document_link_tracing_stub.cc @@ -87,6 +87,18 @@ Status DocumentLinkServiceTracingStub::DeleteDocumentLink( context, *span, child_->DeleteDocumentLink(context, options, request)); } +StatusOr +DocumentLinkServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.contentwarehouse.v1.DocumentLinkService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeDocumentLinkServiceTracingStub( diff --git a/google/cloud/contentwarehouse/v1/internal/document_link_tracing_stub.h b/google/cloud/contentwarehouse/v1/internal/document_link_tracing_stub.h index 1bfb5328963e3..ff1da9d6cf312 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_link_tracing_stub.h +++ b/google/cloud/contentwarehouse/v1/internal/document_link_tracing_stub.h @@ -62,6 +62,10 @@ class DocumentLinkServiceTracingStub : public DocumentLinkServiceStub { google::cloud::contentwarehouse::v1::DeleteDocumentLinkRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/contentwarehouse/v1/internal/document_logging_decorator.cc b/google/cloud/contentwarehouse/v1/internal/document_logging_decorator.cc index 6085ee1b9cdd6..a859786f37b36 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_logging_decorator.cc +++ b/google/cloud/contentwarehouse/v1/internal/document_logging_decorator.cc @@ -139,6 +139,17 @@ DocumentServiceLogging::SetAcl( context, options, request, __func__, tracing_options_); } +StatusOr DocumentServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace contentwarehouse_v1_internal } // namespace cloud diff --git a/google/cloud/contentwarehouse/v1/internal/document_logging_decorator.h b/google/cloud/contentwarehouse/v1/internal/document_logging_decorator.h index 9056298f0c234..6bd8841ee2f24 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_logging_decorator.h +++ b/google/cloud/contentwarehouse/v1/internal/document_logging_decorator.h @@ -81,6 +81,10 @@ class DocumentServiceLogging : public DocumentServiceStub { google::cloud::contentwarehouse::v1::SetAclRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/contentwarehouse/v1/internal/document_metadata_decorator.cc b/google/cloud/contentwarehouse/v1/internal/document_metadata_decorator.cc index 5c0a3fc97ef74..edd11702bfe2c 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_metadata_decorator.cc +++ b/google/cloud/contentwarehouse/v1/internal/document_metadata_decorator.cc @@ -118,6 +118,14 @@ DocumentServiceMetadata::SetAcl( return child_->SetAcl(context, options, request); } +StatusOr DocumentServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + void DocumentServiceMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/contentwarehouse/v1/internal/document_metadata_decorator.h b/google/cloud/contentwarehouse/v1/internal/document_metadata_decorator.h index 78a24b0dcedb5..ff9b071cb10a6 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_metadata_decorator.h +++ b/google/cloud/contentwarehouse/v1/internal/document_metadata_decorator.h @@ -82,6 +82,10 @@ class DocumentServiceMetadata : public DocumentServiceStub { google::cloud::contentwarehouse::v1::SetAclRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/contentwarehouse/v1/internal/document_schema_auth_decorator.cc b/google/cloud/contentwarehouse/v1/internal/document_schema_auth_decorator.cc index 8a0b603ed149c..be98a81f23a53 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_schema_auth_decorator.cc +++ b/google/cloud/contentwarehouse/v1/internal/document_schema_auth_decorator.cc @@ -80,6 +80,15 @@ DocumentSchemaServiceAuth::ListDocumentSchemas( return child_->ListDocumentSchemas(context, options, request); } +StatusOr +DocumentSchemaServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace contentwarehouse_v1_internal } // namespace cloud diff --git a/google/cloud/contentwarehouse/v1/internal/document_schema_auth_decorator.h b/google/cloud/contentwarehouse/v1/internal/document_schema_auth_decorator.h index ca930ed9e3b14..06272dd5e3c22 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_schema_auth_decorator.h +++ b/google/cloud/contentwarehouse/v1/internal/document_schema_auth_decorator.h @@ -67,6 +67,10 @@ class DocumentSchemaServiceAuth : public DocumentSchemaServiceStub { google::cloud::contentwarehouse::v1::ListDocumentSchemasRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/contentwarehouse/v1/internal/document_schema_connection_impl.cc b/google/cloud/contentwarehouse/v1/internal/document_schema_connection_impl.cc index 89d8976e5c4e8..6c1e487cf116e 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_schema_connection_impl.cc +++ b/google/cloud/contentwarehouse/v1/internal/document_schema_connection_impl.cc @@ -166,6 +166,20 @@ DocumentSchemaServiceConnectionImpl::ListDocumentSchemas( }); } +StatusOr +DocumentSchemaServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace contentwarehouse_v1_internal } // namespace cloud diff --git a/google/cloud/contentwarehouse/v1/internal/document_schema_connection_impl.h b/google/cloud/contentwarehouse/v1/internal/document_schema_connection_impl.h index af55229c72e09..7c35a7b519b98 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_schema_connection_impl.h +++ b/google/cloud/contentwarehouse/v1/internal/document_schema_connection_impl.h @@ -74,6 +74,9 @@ class DocumentSchemaServiceConnectionImpl google::cloud::contentwarehouse::v1::ListDocumentSchemasRequest request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr diff --git a/google/cloud/contentwarehouse/v1/internal/document_schema_logging_decorator.cc b/google/cloud/contentwarehouse/v1/internal/document_schema_logging_decorator.cc index 9d406a0bdb9e9..f4280a535b4d4 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_schema_logging_decorator.cc +++ b/google/cloud/contentwarehouse/v1/internal/document_schema_logging_decorator.cc @@ -106,6 +106,18 @@ DocumentSchemaServiceLogging::ListDocumentSchemas( context, options, request, __func__, tracing_options_); } +StatusOr +DocumentSchemaServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace contentwarehouse_v1_internal } // namespace cloud diff --git a/google/cloud/contentwarehouse/v1/internal/document_schema_logging_decorator.h b/google/cloud/contentwarehouse/v1/internal/document_schema_logging_decorator.h index 52d708d1e5ba7..557bc7b7b8f22 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_schema_logging_decorator.h +++ b/google/cloud/contentwarehouse/v1/internal/document_schema_logging_decorator.h @@ -67,6 +67,10 @@ class DocumentSchemaServiceLogging : public DocumentSchemaServiceStub { google::cloud::contentwarehouse::v1::ListDocumentSchemasRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/contentwarehouse/v1/internal/document_schema_metadata_decorator.cc b/google/cloud/contentwarehouse/v1/internal/document_schema_metadata_decorator.cc index 78e7d937c89a7..fa5bfcfb5c70b 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_schema_metadata_decorator.cc +++ b/google/cloud/contentwarehouse/v1/internal/document_schema_metadata_decorator.cc @@ -93,6 +93,15 @@ DocumentSchemaServiceMetadata::ListDocumentSchemas( return child_->ListDocumentSchemas(context, options, request); } +StatusOr +DocumentSchemaServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + void DocumentSchemaServiceMetadata::SetMetadata( grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/contentwarehouse/v1/internal/document_schema_metadata_decorator.h b/google/cloud/contentwarehouse/v1/internal/document_schema_metadata_decorator.h index 78765d165ec1e..00048426f3057 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_schema_metadata_decorator.h +++ b/google/cloud/contentwarehouse/v1/internal/document_schema_metadata_decorator.h @@ -68,6 +68,10 @@ class DocumentSchemaServiceMetadata : public DocumentSchemaServiceStub { google::cloud::contentwarehouse::v1::ListDocumentSchemasRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/contentwarehouse/v1/internal/document_schema_stub.cc b/google/cloud/contentwarehouse/v1/internal/document_schema_stub.cc index b0a30aaf9d08a..b5f90f23da515 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_schema_stub.cc +++ b/google/cloud/contentwarehouse/v1/internal/document_schema_stub.cc @@ -94,6 +94,18 @@ DefaultDocumentSchemaServiceStub::ListDocumentSchemas( return response; } +StatusOr +DefaultDocumentSchemaServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace contentwarehouse_v1_internal } // namespace cloud diff --git a/google/cloud/contentwarehouse/v1/internal/document_schema_stub.h b/google/cloud/contentwarehouse/v1/internal/document_schema_stub.h index e8456a4d544bb..fe28d202c138d 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_schema_stub.h +++ b/google/cloud/contentwarehouse/v1/internal/document_schema_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -64,6 +65,10 @@ class DocumentSchemaServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::contentwarehouse::v1::ListDocumentSchemasRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; }; class DefaultDocumentSchemaServiceStub : public DocumentSchemaServiceStub { @@ -71,8 +76,11 @@ class DefaultDocumentSchemaServiceStub : public DocumentSchemaServiceStub { explicit DefaultDocumentSchemaServiceStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr CreateDocumentSchema( @@ -103,10 +111,16 @@ class DefaultDocumentSchemaServiceStub : public DocumentSchemaServiceStub { google::cloud::contentwarehouse::v1::ListDocumentSchemasRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr< google::cloud::contentwarehouse::v1::DocumentSchemaService::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/contentwarehouse/v1/internal/document_schema_stub_factory.cc b/google/cloud/contentwarehouse/v1/internal/document_schema_stub_factory.cc index 2b252c74dff64..c206a6822428a 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_schema_stub_factory.cc +++ b/google/cloud/contentwarehouse/v1/internal/document_schema_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 @@ CreateDefaultDocumentSchemaServiceStub( auto service_grpc_stub = google::cloud::contentwarehouse::v1::DocumentSchemaService::NewStub( channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_operations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/contentwarehouse/v1/internal/document_schema_tracing_connection.cc b/google/cloud/contentwarehouse/v1/internal/document_schema_tracing_connection.cc index a07738438dcf3..837217d615dbd 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_schema_tracing_connection.cc +++ b/google/cloud/contentwarehouse/v1/internal/document_schema_tracing_connection.cc @@ -89,6 +89,15 @@ DocumentSchemaServiceTracingConnection::ListDocumentSchemas( std::move(sr)); } +StatusOr +DocumentSchemaServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "contentwarehouse_v1::DocumentSchemaServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/contentwarehouse/v1/internal/document_schema_tracing_connection.h b/google/cloud/contentwarehouse/v1/internal/document_schema_tracing_connection.h index 3fcebab524046..acfc27b0ad6e5 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_schema_tracing_connection.h +++ b/google/cloud/contentwarehouse/v1/internal/document_schema_tracing_connection.h @@ -65,6 +65,9 @@ class DocumentSchemaServiceTracingConnection google::cloud::contentwarehouse::v1::ListDocumentSchemasRequest request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/contentwarehouse/v1/internal/document_schema_tracing_stub.cc b/google/cloud/contentwarehouse/v1/internal/document_schema_tracing_stub.cc index e43f2edfec548..046918e125192 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_schema_tracing_stub.cc +++ b/google/cloud/contentwarehouse/v1/internal/document_schema_tracing_stub.cc @@ -101,6 +101,18 @@ DocumentSchemaServiceTracingStub::ListDocumentSchemas( context, *span, child_->ListDocumentSchemas(context, options, request)); } +StatusOr +DocumentSchemaServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.contentwarehouse.v1.DocumentSchemaService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeDocumentSchemaServiceTracingStub( diff --git a/google/cloud/contentwarehouse/v1/internal/document_schema_tracing_stub.h b/google/cloud/contentwarehouse/v1/internal/document_schema_tracing_stub.h index 5cb7c6da3adce..aff71233fe280 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_schema_tracing_stub.h +++ b/google/cloud/contentwarehouse/v1/internal/document_schema_tracing_stub.h @@ -68,6 +68,10 @@ class DocumentSchemaServiceTracingStub : public DocumentSchemaServiceStub { google::cloud::contentwarehouse::v1::ListDocumentSchemasRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/contentwarehouse/v1/internal/document_stub.cc b/google/cloud/contentwarehouse/v1/internal/document_stub.cc index e3fba087ec661..0056d39943e2b 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_stub.cc +++ b/google/cloud/contentwarehouse/v1/internal/document_stub.cc @@ -126,6 +126,18 @@ DefaultDocumentServiceStub::SetAcl( return response; } +StatusOr +DefaultDocumentServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace contentwarehouse_v1_internal } // namespace cloud diff --git a/google/cloud/contentwarehouse/v1/internal/document_stub.h b/google/cloud/contentwarehouse/v1/internal/document_stub.h index fa79c709c8ad5..1d2b340d5f42c 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_stub.h +++ b/google/cloud/contentwarehouse/v1/internal/document_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -76,6 +77,10 @@ class DocumentServiceStub { virtual StatusOr SetAcl( grpc::ClientContext& context, Options const& options, google::cloud::contentwarehouse::v1::SetAclRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; }; class DefaultDocumentServiceStub : public DocumentServiceStub { @@ -83,8 +88,11 @@ class DefaultDocumentServiceStub : public DocumentServiceStub { explicit DefaultDocumentServiceStub( std::unique_ptr< google::cloud::contentwarehouse::v1::DocumentService::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr CreateDocument( @@ -129,10 +137,16 @@ class DefaultDocumentServiceStub : public DocumentServiceStub { google::cloud::contentwarehouse::v1::SetAclRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr< google::cloud::contentwarehouse::v1::DocumentService::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/contentwarehouse/v1/internal/document_stub_factory.cc b/google/cloud/contentwarehouse/v1/internal/document_stub_factory.cc index f448f6208deca..fce775c02c652 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_stub_factory.cc +++ b/google/cloud/contentwarehouse/v1/internal/document_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 CreateDefaultDocumentServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::contentwarehouse::v1::DocumentService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_operations_stub)); if (auth->RequiresConfigureContext()) { stub = diff --git a/google/cloud/contentwarehouse/v1/internal/document_tracing_connection.cc b/google/cloud/contentwarehouse/v1/internal/document_tracing_connection.cc index ebc092715bb4b..df7383aaa15a3 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_tracing_connection.cc +++ b/google/cloud/contentwarehouse/v1/internal/document_tracing_connection.cc @@ -108,6 +108,15 @@ DocumentServiceTracingConnection::SetAcl( return internal::EndSpan(*span, child_->SetAcl(request)); } +StatusOr +DocumentServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "contentwarehouse_v1::DocumentServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/contentwarehouse/v1/internal/document_tracing_connection.h b/google/cloud/contentwarehouse/v1/internal/document_tracing_connection.h index 898cf7f368cc7..5af3d469fa257 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_tracing_connection.h +++ b/google/cloud/contentwarehouse/v1/internal/document_tracing_connection.h @@ -75,6 +75,9 @@ class DocumentServiceTracingConnection google::cloud::contentwarehouse::v1::SetAclRequest const& request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/contentwarehouse/v1/internal/document_tracing_stub.cc b/google/cloud/contentwarehouse/v1/internal/document_tracing_stub.cc index 29dd7003ac4f0..9d3b1616e366a 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_tracing_stub.cc +++ b/google/cloud/contentwarehouse/v1/internal/document_tracing_stub.cc @@ -128,6 +128,18 @@ DocumentServiceTracingStub::SetAcl( child_->SetAcl(context, options, request)); } +StatusOr +DocumentServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.contentwarehouse.v1.DocumentService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeDocumentServiceTracingStub( diff --git a/google/cloud/contentwarehouse/v1/internal/document_tracing_stub.h b/google/cloud/contentwarehouse/v1/internal/document_tracing_stub.h index 761c3abf6f7f3..60f94eea40e65 100644 --- a/google/cloud/contentwarehouse/v1/internal/document_tracing_stub.h +++ b/google/cloud/contentwarehouse/v1/internal/document_tracing_stub.h @@ -82,6 +82,10 @@ class DocumentServiceTracingStub : public DocumentServiceStub { google::cloud::contentwarehouse::v1::SetAclRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/contentwarehouse/v1/internal/pipeline_auth_decorator.cc b/google/cloud/contentwarehouse/v1/internal/pipeline_auth_decorator.cc index 71617639965b0..dc0b668dfa452 100644 --- a/google/cloud/contentwarehouse/v1/internal/pipeline_auth_decorator.cc +++ b/google/cloud/contentwarehouse/v1/internal/pipeline_auth_decorator.cc @@ -59,6 +59,14 @@ StatusOr PipelineServiceAuth::RunPipeline( return child_->RunPipeline(context, options, request); } +StatusOr PipelineServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + future> PipelineServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/contentwarehouse/v1/internal/pipeline_auth_decorator.h b/google/cloud/contentwarehouse/v1/internal/pipeline_auth_decorator.h index 45f18401fc1d7..cf8ba9e1d20ee 100644 --- a/google/cloud/contentwarehouse/v1/internal/pipeline_auth_decorator.h +++ b/google/cloud/contentwarehouse/v1/internal/pipeline_auth_decorator.h @@ -51,6 +51,10 @@ class PipelineServiceAuth : public PipelineServiceStub { google::cloud::contentwarehouse::v1::RunPipelineRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/contentwarehouse/v1/internal/pipeline_connection_impl.cc b/google/cloud/contentwarehouse/v1/internal/pipeline_connection_impl.cc index 5d0ced18ff35d..a979ed12eed38 100644 --- a/google/cloud/contentwarehouse/v1/internal/pipeline_connection_impl.cc +++ b/google/cloud/contentwarehouse/v1/internal/pipeline_connection_impl.cc @@ -161,6 +161,20 @@ PipelineServiceConnectionImpl::RunPipeline( polling_policy(*current), __func__); } +StatusOr +PipelineServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace contentwarehouse_v1_internal } // namespace cloud diff --git a/google/cloud/contentwarehouse/v1/internal/pipeline_connection_impl.h b/google/cloud/contentwarehouse/v1/internal/pipeline_connection_impl.h index 83d267610f632..3782eb9922589 100644 --- a/google/cloud/contentwarehouse/v1/internal/pipeline_connection_impl.h +++ b/google/cloud/contentwarehouse/v1/internal/pipeline_connection_impl.h @@ -63,6 +63,9 @@ class PipelineServiceConnectionImpl future> RunPipeline(google::longrunning::Operation const& operation) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/contentwarehouse/v1/internal/pipeline_logging_decorator.cc b/google/cloud/contentwarehouse/v1/internal/pipeline_logging_decorator.cc index 9494ac62ea589..af3d140cad4f6 100644 --- a/google/cloud/contentwarehouse/v1/internal/pipeline_logging_decorator.cc +++ b/google/cloud/contentwarehouse/v1/internal/pipeline_logging_decorator.cc @@ -66,6 +66,17 @@ StatusOr PipelineServiceLogging::RunPipeline( context, options, request, __func__, tracing_options_); } +StatusOr PipelineServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> PipelineServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/contentwarehouse/v1/internal/pipeline_logging_decorator.h b/google/cloud/contentwarehouse/v1/internal/pipeline_logging_decorator.h index 925532bb5d703..5fa75955414de 100644 --- a/google/cloud/contentwarehouse/v1/internal/pipeline_logging_decorator.h +++ b/google/cloud/contentwarehouse/v1/internal/pipeline_logging_decorator.h @@ -51,6 +51,10 @@ class PipelineServiceLogging : public PipelineServiceStub { google::cloud::contentwarehouse::v1::RunPipelineRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/contentwarehouse/v1/internal/pipeline_metadata_decorator.cc b/google/cloud/contentwarehouse/v1/internal/pipeline_metadata_decorator.cc index 0f6ea72629ea8..7ca500b1f6536 100644 --- a/google/cloud/contentwarehouse/v1/internal/pipeline_metadata_decorator.cc +++ b/google/cloud/contentwarehouse/v1/internal/pipeline_metadata_decorator.cc @@ -64,6 +64,14 @@ StatusOr PipelineServiceMetadata::RunPipeline( return child_->RunPipeline(context, options, request); } +StatusOr PipelineServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + future> PipelineServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/contentwarehouse/v1/internal/pipeline_metadata_decorator.h b/google/cloud/contentwarehouse/v1/internal/pipeline_metadata_decorator.h index f58ece23c1a27..7635e920db968 100644 --- a/google/cloud/contentwarehouse/v1/internal/pipeline_metadata_decorator.h +++ b/google/cloud/contentwarehouse/v1/internal/pipeline_metadata_decorator.h @@ -52,6 +52,10 @@ class PipelineServiceMetadata : public PipelineServiceStub { google::cloud::contentwarehouse::v1::RunPipelineRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/contentwarehouse/v1/internal/pipeline_stub.cc b/google/cloud/contentwarehouse/v1/internal/pipeline_stub.cc index b5e9b730a0024..133e06a328cf1 100644 --- a/google/cloud/contentwarehouse/v1/internal/pipeline_stub.cc +++ b/google/cloud/contentwarehouse/v1/internal/pipeline_stub.cc @@ -62,6 +62,18 @@ DefaultPipelineServiceStub::RunPipeline( return response; } +StatusOr +DefaultPipelineServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&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/contentwarehouse/v1/internal/pipeline_stub.h b/google/cloud/contentwarehouse/v1/internal/pipeline_stub.h index a37df44ca81dd..17958b1b74be6 100644 --- a/google/cloud/contentwarehouse/v1/internal/pipeline_stub.h +++ b/google/cloud/contentwarehouse/v1/internal/pipeline_stub.h @@ -50,6 +50,10 @@ class PipelineServiceStub { google::cloud::contentwarehouse::v1::RunPipelineRequest const& request) = 0; + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -69,9 +73,13 @@ class DefaultPipelineServiceStub : public PipelineServiceStub { std::unique_ptr< google::cloud::contentwarehouse::v1::PipelineService::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} future> AsyncRunPipeline( google::cloud::CompletionQueue& cq, @@ -85,6 +93,10 @@ class DefaultPipelineServiceStub : public PipelineServiceStub { google::cloud::contentwarehouse::v1::RunPipelineRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -101,6 +113,8 @@ class DefaultPipelineServiceStub : public PipelineServiceStub { std::unique_ptr< google::cloud::contentwarehouse::v1::PipelineService::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/contentwarehouse/v1/internal/pipeline_stub_factory.cc b/google/cloud/contentwarehouse/v1/internal/pipeline_stub_factory.cc index 07f691764f15f..5400c6e574945 100644 --- a/google/cloud/contentwarehouse/v1/internal/pipeline_stub_factory.cc +++ b/google/cloud/contentwarehouse/v1/internal/pipeline_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 CreateDefaultPipelineServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::contentwarehouse::v1::PipelineService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/contentwarehouse/v1/internal/pipeline_tracing_connection.cc b/google/cloud/contentwarehouse/v1/internal/pipeline_tracing_connection.cc index f954bd9c78ecb..d3de82f3ebb26 100644 --- a/google/cloud/contentwarehouse/v1/internal/pipeline_tracing_connection.cc +++ b/google/cloud/contentwarehouse/v1/internal/pipeline_tracing_connection.cc @@ -60,6 +60,15 @@ PipelineServiceTracingConnection::RunPipeline( return internal::EndSpan(std::move(span), child_->RunPipeline(operation)); } +StatusOr +PipelineServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "contentwarehouse_v1::PipelineServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/contentwarehouse/v1/internal/pipeline_tracing_connection.h b/google/cloud/contentwarehouse/v1/internal/pipeline_tracing_connection.h index 4b2eb33b59f5e..d8d73dec5e33f 100644 --- a/google/cloud/contentwarehouse/v1/internal/pipeline_tracing_connection.h +++ b/google/cloud/contentwarehouse/v1/internal/pipeline_tracing_connection.h @@ -52,6 +52,9 @@ class PipelineServiceTracingConnection future> RunPipeline(google::longrunning::Operation const& operation) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/contentwarehouse/v1/internal/pipeline_tracing_stub.cc b/google/cloud/contentwarehouse/v1/internal/pipeline_tracing_stub.cc index 46b13d5771ecf..a9556c5946158 100644 --- a/google/cloud/contentwarehouse/v1/internal/pipeline_tracing_stub.cc +++ b/google/cloud/contentwarehouse/v1/internal/pipeline_tracing_stub.cc @@ -58,6 +58,18 @@ PipelineServiceTracingStub::RunPipeline( child_->RunPipeline(context, options, request)); } +StatusOr +PipelineServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.contentwarehouse.v1.PipelineService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + future> PipelineServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/contentwarehouse/v1/internal/pipeline_tracing_stub.h b/google/cloud/contentwarehouse/v1/internal/pipeline_tracing_stub.h index 82f9e8cb0bf0d..5eb7b04a69086 100644 --- a/google/cloud/contentwarehouse/v1/internal/pipeline_tracing_stub.h +++ b/google/cloud/contentwarehouse/v1/internal/pipeline_tracing_stub.h @@ -51,6 +51,10 @@ class PipelineServiceTracingStub : public PipelineServiceStub { google::cloud::contentwarehouse::v1::RunPipelineRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/contentwarehouse/v1/internal/rule_set_auth_decorator.cc b/google/cloud/contentwarehouse/v1/internal/rule_set_auth_decorator.cc index a3add0b0e17be..cb7f49891c55a 100644 --- a/google/cloud/contentwarehouse/v1/internal/rule_set_auth_decorator.cc +++ b/google/cloud/contentwarehouse/v1/internal/rule_set_auth_decorator.cc @@ -75,6 +75,14 @@ RuleSetServiceAuth::ListRuleSets( return child_->ListRuleSets(context, options, request); } +StatusOr RuleSetServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace contentwarehouse_v1_internal } // namespace cloud diff --git a/google/cloud/contentwarehouse/v1/internal/rule_set_auth_decorator.h b/google/cloud/contentwarehouse/v1/internal/rule_set_auth_decorator.h index b72592746dbdb..f015e782ba22b 100644 --- a/google/cloud/contentwarehouse/v1/internal/rule_set_auth_decorator.h +++ b/google/cloud/contentwarehouse/v1/internal/rule_set_auth_decorator.h @@ -63,6 +63,10 @@ class RuleSetServiceAuth : public RuleSetServiceStub { google::cloud::contentwarehouse::v1::ListRuleSetsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/contentwarehouse/v1/internal/rule_set_connection_impl.cc b/google/cloud/contentwarehouse/v1/internal/rule_set_connection_impl.cc index 504a10e7e9200..a3070c8e4355e 100644 --- a/google/cloud/contentwarehouse/v1/internal/rule_set_connection_impl.cc +++ b/google/cloud/contentwarehouse/v1/internal/rule_set_connection_impl.cc @@ -156,6 +156,20 @@ RuleSetServiceConnectionImpl::ListRuleSets( }); } +StatusOr +RuleSetServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace contentwarehouse_v1_internal } // namespace cloud diff --git a/google/cloud/contentwarehouse/v1/internal/rule_set_connection_impl.h b/google/cloud/contentwarehouse/v1/internal/rule_set_connection_impl.h index d023100093258..15d573e4405e9 100644 --- a/google/cloud/contentwarehouse/v1/internal/rule_set_connection_impl.h +++ b/google/cloud/contentwarehouse/v1/internal/rule_set_connection_impl.h @@ -69,6 +69,9 @@ class RuleSetServiceConnectionImpl google::cloud::contentwarehouse::v1::ListRuleSetsRequest request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/contentwarehouse/v1/internal/rule_set_logging_decorator.cc b/google/cloud/contentwarehouse/v1/internal/rule_set_logging_decorator.cc index 209e159dea1e0..37420f218df31 100644 --- a/google/cloud/contentwarehouse/v1/internal/rule_set_logging_decorator.cc +++ b/google/cloud/contentwarehouse/v1/internal/rule_set_logging_decorator.cc @@ -99,6 +99,17 @@ RuleSetServiceLogging::ListRuleSets( context, options, request, __func__, tracing_options_); } +StatusOr RuleSetServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace contentwarehouse_v1_internal } // namespace cloud diff --git a/google/cloud/contentwarehouse/v1/internal/rule_set_logging_decorator.h b/google/cloud/contentwarehouse/v1/internal/rule_set_logging_decorator.h index d527cbaa7dd68..8b6b767b46673 100644 --- a/google/cloud/contentwarehouse/v1/internal/rule_set_logging_decorator.h +++ b/google/cloud/contentwarehouse/v1/internal/rule_set_logging_decorator.h @@ -63,6 +63,10 @@ class RuleSetServiceLogging : public RuleSetServiceStub { google::cloud::contentwarehouse::v1::ListRuleSetsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/contentwarehouse/v1/internal/rule_set_metadata_decorator.cc b/google/cloud/contentwarehouse/v1/internal/rule_set_metadata_decorator.cc index 1919641625786..6e6edad9f52f3 100644 --- a/google/cloud/contentwarehouse/v1/internal/rule_set_metadata_decorator.cc +++ b/google/cloud/contentwarehouse/v1/internal/rule_set_metadata_decorator.cc @@ -88,6 +88,14 @@ RuleSetServiceMetadata::ListRuleSets( return child_->ListRuleSets(context, options, request); } +StatusOr RuleSetServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + void RuleSetServiceMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/contentwarehouse/v1/internal/rule_set_metadata_decorator.h b/google/cloud/contentwarehouse/v1/internal/rule_set_metadata_decorator.h index d8f1f33bdba64..1a28ac7a391a0 100644 --- a/google/cloud/contentwarehouse/v1/internal/rule_set_metadata_decorator.h +++ b/google/cloud/contentwarehouse/v1/internal/rule_set_metadata_decorator.h @@ -63,6 +63,10 @@ class RuleSetServiceMetadata : public RuleSetServiceStub { google::cloud::contentwarehouse::v1::ListRuleSetsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/contentwarehouse/v1/internal/rule_set_stub.cc b/google/cloud/contentwarehouse/v1/internal/rule_set_stub.cc index 37965af6a6589..82ee24c4d4b6a 100644 --- a/google/cloud/contentwarehouse/v1/internal/rule_set_stub.cc +++ b/google/cloud/contentwarehouse/v1/internal/rule_set_stub.cc @@ -89,6 +89,18 @@ DefaultRuleSetServiceStub::ListRuleSets( return response; } +StatusOr +DefaultRuleSetServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace contentwarehouse_v1_internal } // namespace cloud diff --git a/google/cloud/contentwarehouse/v1/internal/rule_set_stub.h b/google/cloud/contentwarehouse/v1/internal/rule_set_stub.h index 6c0f91b3d957c..43ae676998869 100644 --- a/google/cloud/contentwarehouse/v1/internal/rule_set_stub.h +++ b/google/cloud/contentwarehouse/v1/internal/rule_set_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -59,6 +60,10 @@ class RuleSetServiceStub { ListRuleSets(grpc::ClientContext& context, Options const& options, google::cloud::contentwarehouse::v1::ListRuleSetsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; }; class DefaultRuleSetServiceStub : public RuleSetServiceStub { @@ -66,8 +71,11 @@ class DefaultRuleSetServiceStub : public RuleSetServiceStub { explicit DefaultRuleSetServiceStub( std::unique_ptr< google::cloud::contentwarehouse::v1::RuleSetService::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr CreateRuleSet( grpc::ClientContext& context, Options const& options, @@ -94,10 +102,16 @@ class DefaultRuleSetServiceStub : public RuleSetServiceStub { google::cloud::contentwarehouse::v1::ListRuleSetsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr< google::cloud::contentwarehouse::v1::RuleSetService::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/contentwarehouse/v1/internal/rule_set_stub_factory.cc b/google/cloud/contentwarehouse/v1/internal/rule_set_stub_factory.cc index 5e3a6c18f985b..a6bf26af3ab4a 100644 --- a/google/cloud/contentwarehouse/v1/internal/rule_set_stub_factory.cc +++ b/google/cloud/contentwarehouse/v1/internal/rule_set_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 CreateDefaultRuleSetServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::contentwarehouse::v1::RuleSetService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_stub)); if (auth->RequiresConfigureContext()) { stub = diff --git a/google/cloud/contentwarehouse/v1/internal/rule_set_tracing_connection.cc b/google/cloud/contentwarehouse/v1/internal/rule_set_tracing_connection.cc index 644395419b600..3c4b92ca28914 100644 --- a/google/cloud/contentwarehouse/v1/internal/rule_set_tracing_connection.cc +++ b/google/cloud/contentwarehouse/v1/internal/rule_set_tracing_connection.cc @@ -80,6 +80,15 @@ RuleSetServiceTracingConnection::ListRuleSets( std::move(sr)); } +StatusOr +RuleSetServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "contentwarehouse_v1::RuleSetServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/contentwarehouse/v1/internal/rule_set_tracing_connection.h b/google/cloud/contentwarehouse/v1/internal/rule_set_tracing_connection.h index 8e1362f735dc5..eab8ad7ff8cbd 100644 --- a/google/cloud/contentwarehouse/v1/internal/rule_set_tracing_connection.h +++ b/google/cloud/contentwarehouse/v1/internal/rule_set_tracing_connection.h @@ -60,6 +60,9 @@ class RuleSetServiceTracingConnection google::cloud::contentwarehouse::v1::ListRuleSetsRequest request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/contentwarehouse/v1/internal/rule_set_tracing_stub.cc b/google/cloud/contentwarehouse/v1/internal/rule_set_tracing_stub.cc index 7ba62c7c33c0f..c23759fb7d9c7 100644 --- a/google/cloud/contentwarehouse/v1/internal/rule_set_tracing_stub.cc +++ b/google/cloud/contentwarehouse/v1/internal/rule_set_tracing_stub.cc @@ -91,6 +91,18 @@ RuleSetServiceTracingStub::ListRuleSets( child_->ListRuleSets(context, options, request)); } +StatusOr +RuleSetServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.contentwarehouse.v1.RuleSetService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeRuleSetServiceTracingStub( diff --git a/google/cloud/contentwarehouse/v1/internal/rule_set_tracing_stub.h b/google/cloud/contentwarehouse/v1/internal/rule_set_tracing_stub.h index dc9a867d339fd..16cdce7cc9132 100644 --- a/google/cloud/contentwarehouse/v1/internal/rule_set_tracing_stub.h +++ b/google/cloud/contentwarehouse/v1/internal/rule_set_tracing_stub.h @@ -63,6 +63,10 @@ class RuleSetServiceTracingStub : public RuleSetServiceStub { google::cloud::contentwarehouse::v1::ListRuleSetsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/contentwarehouse/v1/internal/synonym_set_auth_decorator.cc b/google/cloud/contentwarehouse/v1/internal/synonym_set_auth_decorator.cc index 7462546e3868f..4edd992bc7c7a 100644 --- a/google/cloud/contentwarehouse/v1/internal/synonym_set_auth_decorator.cc +++ b/google/cloud/contentwarehouse/v1/internal/synonym_set_auth_decorator.cc @@ -79,6 +79,14 @@ SynonymSetServiceAuth::ListSynonymSets( return child_->ListSynonymSets(context, options, request); } +StatusOr SynonymSetServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace contentwarehouse_v1_internal } // namespace cloud diff --git a/google/cloud/contentwarehouse/v1/internal/synonym_set_auth_decorator.h b/google/cloud/contentwarehouse/v1/internal/synonym_set_auth_decorator.h index f6daf7185a915..e8b162485a4c2 100644 --- a/google/cloud/contentwarehouse/v1/internal/synonym_set_auth_decorator.h +++ b/google/cloud/contentwarehouse/v1/internal/synonym_set_auth_decorator.h @@ -64,6 +64,10 @@ class SynonymSetServiceAuth : public SynonymSetServiceStub { google::cloud::contentwarehouse::v1::ListSynonymSetsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/contentwarehouse/v1/internal/synonym_set_connection_impl.cc b/google/cloud/contentwarehouse/v1/internal/synonym_set_connection_impl.cc index 1f4a0e7487b1f..501cd32888ad6 100644 --- a/google/cloud/contentwarehouse/v1/internal/synonym_set_connection_impl.cc +++ b/google/cloud/contentwarehouse/v1/internal/synonym_set_connection_impl.cc @@ -162,6 +162,20 @@ SynonymSetServiceConnectionImpl::ListSynonymSets( }); } +StatusOr +SynonymSetServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace contentwarehouse_v1_internal } // namespace cloud diff --git a/google/cloud/contentwarehouse/v1/internal/synonym_set_connection_impl.h b/google/cloud/contentwarehouse/v1/internal/synonym_set_connection_impl.h index f4fbc8c2d8a4b..834c5fcfd0d34 100644 --- a/google/cloud/contentwarehouse/v1/internal/synonym_set_connection_impl.h +++ b/google/cloud/contentwarehouse/v1/internal/synonym_set_connection_impl.h @@ -69,6 +69,9 @@ class SynonymSetServiceConnectionImpl google::cloud::contentwarehouse::v1::ListSynonymSetsRequest request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/contentwarehouse/v1/internal/synonym_set_logging_decorator.cc b/google/cloud/contentwarehouse/v1/internal/synonym_set_logging_decorator.cc index 3394cdfa3bc7a..0d4adcce19d2f 100644 --- a/google/cloud/contentwarehouse/v1/internal/synonym_set_logging_decorator.cc +++ b/google/cloud/contentwarehouse/v1/internal/synonym_set_logging_decorator.cc @@ -103,6 +103,17 @@ SynonymSetServiceLogging::ListSynonymSets( context, options, request, __func__, tracing_options_); } +StatusOr SynonymSetServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace contentwarehouse_v1_internal } // namespace cloud diff --git a/google/cloud/contentwarehouse/v1/internal/synonym_set_logging_decorator.h b/google/cloud/contentwarehouse/v1/internal/synonym_set_logging_decorator.h index b9bf41be8b2b4..724fce941f5f1 100644 --- a/google/cloud/contentwarehouse/v1/internal/synonym_set_logging_decorator.h +++ b/google/cloud/contentwarehouse/v1/internal/synonym_set_logging_decorator.h @@ -64,6 +64,10 @@ class SynonymSetServiceLogging : public SynonymSetServiceStub { google::cloud::contentwarehouse::v1::ListSynonymSetsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/contentwarehouse/v1/internal/synonym_set_metadata_decorator.cc b/google/cloud/contentwarehouse/v1/internal/synonym_set_metadata_decorator.cc index c51079d74f952..0b7f711cb0fd7 100644 --- a/google/cloud/contentwarehouse/v1/internal/synonym_set_metadata_decorator.cc +++ b/google/cloud/contentwarehouse/v1/internal/synonym_set_metadata_decorator.cc @@ -92,6 +92,15 @@ SynonymSetServiceMetadata::ListSynonymSets( return child_->ListSynonymSets(context, options, request); } +StatusOr +SynonymSetServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + void SynonymSetServiceMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/contentwarehouse/v1/internal/synonym_set_metadata_decorator.h b/google/cloud/contentwarehouse/v1/internal/synonym_set_metadata_decorator.h index 236e0c687b25c..ccd0100ad5ee1 100644 --- a/google/cloud/contentwarehouse/v1/internal/synonym_set_metadata_decorator.h +++ b/google/cloud/contentwarehouse/v1/internal/synonym_set_metadata_decorator.h @@ -65,6 +65,10 @@ class SynonymSetServiceMetadata : public SynonymSetServiceStub { google::cloud::contentwarehouse::v1::ListSynonymSetsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/contentwarehouse/v1/internal/synonym_set_stub.cc b/google/cloud/contentwarehouse/v1/internal/synonym_set_stub.cc index 693fcd86433bf..ca470a9247428 100644 --- a/google/cloud/contentwarehouse/v1/internal/synonym_set_stub.cc +++ b/google/cloud/contentwarehouse/v1/internal/synonym_set_stub.cc @@ -93,6 +93,18 @@ DefaultSynonymSetServiceStub::ListSynonymSets( return response; } +StatusOr +DefaultSynonymSetServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace contentwarehouse_v1_internal } // namespace cloud diff --git a/google/cloud/contentwarehouse/v1/internal/synonym_set_stub.h b/google/cloud/contentwarehouse/v1/internal/synonym_set_stub.h index b759d0c94de16..8dfc31f47fec7 100644 --- a/google/cloud/contentwarehouse/v1/internal/synonym_set_stub.h +++ b/google/cloud/contentwarehouse/v1/internal/synonym_set_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -62,6 +63,10 @@ class SynonymSetServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::contentwarehouse::v1::ListSynonymSetsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; }; class DefaultSynonymSetServiceStub : public SynonymSetServiceStub { @@ -69,8 +74,11 @@ class DefaultSynonymSetServiceStub : public SynonymSetServiceStub { explicit DefaultSynonymSetServiceStub( std::unique_ptr< google::cloud::contentwarehouse::v1::SynonymSetService::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr CreateSynonymSet( grpc::ClientContext& context, Options const& options, @@ -98,10 +106,16 @@ class DefaultSynonymSetServiceStub : public SynonymSetServiceStub { google::cloud::contentwarehouse::v1::ListSynonymSetsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr< google::cloud::contentwarehouse::v1::SynonymSetService::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/contentwarehouse/v1/internal/synonym_set_stub_factory.cc b/google/cloud/contentwarehouse/v1/internal/synonym_set_stub_factory.cc index 98ac8096ce768..759edc82ec2dd 100644 --- a/google/cloud/contentwarehouse/v1/internal/synonym_set_stub_factory.cc +++ b/google/cloud/contentwarehouse/v1/internal/synonym_set_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 CreateDefaultSynonymSetServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::contentwarehouse::v1::SynonymSetService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_operations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/contentwarehouse/v1/internal/synonym_set_tracing_connection.cc b/google/cloud/contentwarehouse/v1/internal/synonym_set_tracing_connection.cc index 061e38547f414..bb2865afc18ca 100644 --- a/google/cloud/contentwarehouse/v1/internal/synonym_set_tracing_connection.cc +++ b/google/cloud/contentwarehouse/v1/internal/synonym_set_tracing_connection.cc @@ -83,6 +83,15 @@ SynonymSetServiceTracingConnection::ListSynonymSets( std::move(sr)); } +StatusOr +SynonymSetServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "contentwarehouse_v1::SynonymSetServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/contentwarehouse/v1/internal/synonym_set_tracing_connection.h b/google/cloud/contentwarehouse/v1/internal/synonym_set_tracing_connection.h index 09b2cf96e2863..4d6c0995b8d5e 100644 --- a/google/cloud/contentwarehouse/v1/internal/synonym_set_tracing_connection.h +++ b/google/cloud/contentwarehouse/v1/internal/synonym_set_tracing_connection.h @@ -60,6 +60,9 @@ class SynonymSetServiceTracingConnection google::cloud::contentwarehouse::v1::ListSynonymSetsRequest request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/contentwarehouse/v1/internal/synonym_set_tracing_stub.cc b/google/cloud/contentwarehouse/v1/internal/synonym_set_tracing_stub.cc index c8bcce67ab1f2..62c5c7b891ab8 100644 --- a/google/cloud/contentwarehouse/v1/internal/synonym_set_tracing_stub.cc +++ b/google/cloud/contentwarehouse/v1/internal/synonym_set_tracing_stub.cc @@ -95,6 +95,18 @@ SynonymSetServiceTracingStub::ListSynonymSets( child_->ListSynonymSets(context, options, request)); } +StatusOr +SynonymSetServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.contentwarehouse.v1.SynonymSetService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeSynonymSetServiceTracingStub( diff --git a/google/cloud/contentwarehouse/v1/internal/synonym_set_tracing_stub.h b/google/cloud/contentwarehouse/v1/internal/synonym_set_tracing_stub.h index 511ee48ca74e5..15a5990dd591f 100644 --- a/google/cloud/contentwarehouse/v1/internal/synonym_set_tracing_stub.h +++ b/google/cloud/contentwarehouse/v1/internal/synonym_set_tracing_stub.h @@ -65,6 +65,10 @@ class SynonymSetServiceTracingStub : public SynonymSetServiceStub { google::cloud::contentwarehouse::v1::ListSynonymSetsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/contentwarehouse/v1/mocks/mock_document_connection.h b/google/cloud/contentwarehouse/v1/mocks/mock_document_connection.h index e104c6b261d60..cba167c84c7f7 100644 --- a/google/cloud/contentwarehouse/v1/mocks/mock_document_connection.h +++ b/google/cloud/contentwarehouse/v1/mocks/mock_document_connection.h @@ -92,6 +92,10 @@ class MockDocumentServiceConnection StatusOr, SetAcl, (google::cloud::contentwarehouse::v1::SetAclRequest const& request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/contentwarehouse/v1/mocks/mock_document_link_connection.h b/google/cloud/contentwarehouse/v1/mocks/mock_document_link_connection.h index a1b1ceb61f3d6..c7cbd5233971c 100644 --- a/google/cloud/contentwarehouse/v1/mocks/mock_document_link_connection.h +++ b/google/cloud/contentwarehouse/v1/mocks/mock_document_link_connection.h @@ -72,6 +72,10 @@ class MockDocumentLinkServiceConnection (google::cloud::contentwarehouse::v1::DeleteDocumentLinkRequest const& request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/contentwarehouse/v1/mocks/mock_document_schema_connection.h b/google/cloud/contentwarehouse/v1/mocks/mock_document_schema_connection.h index 21a32d7a44716..a1a9fd36efa1c 100644 --- a/google/cloud/contentwarehouse/v1/mocks/mock_document_schema_connection.h +++ b/google/cloud/contentwarehouse/v1/mocks/mock_document_schema_connection.h @@ -79,6 +79,10 @@ class MockDocumentSchemaServiceConnection ListDocumentSchemas, (google::cloud::contentwarehouse::v1::ListDocumentSchemasRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/contentwarehouse/v1/mocks/mock_pipeline_connection.h b/google/cloud/contentwarehouse/v1/mocks/mock_pipeline_connection.h index ce2b16d2e0396..9d1e7d36a37dc 100644 --- a/google/cloud/contentwarehouse/v1/mocks/mock_pipeline_connection.h +++ b/google/cloud/contentwarehouse/v1/mocks/mock_pipeline_connection.h @@ -88,6 +88,10 @@ class MockPipelineServiceConnection StatusOr>, RunPipeline, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/contentwarehouse/v1/mocks/mock_rule_set_connection.h b/google/cloud/contentwarehouse/v1/mocks/mock_rule_set_connection.h index c9a5b390ed8ec..f2b44d70e069a 100644 --- a/google/cloud/contentwarehouse/v1/mocks/mock_rule_set_connection.h +++ b/google/cloud/contentwarehouse/v1/mocks/mock_rule_set_connection.h @@ -73,6 +73,10 @@ class MockRuleSetServiceConnection (StreamRange), ListRuleSets, (google::cloud::contentwarehouse::v1::ListRuleSetsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/contentwarehouse/v1/mocks/mock_synonym_set_connection.h b/google/cloud/contentwarehouse/v1/mocks/mock_synonym_set_connection.h index d24cf1c510b0e..717296627a979 100644 --- a/google/cloud/contentwarehouse/v1/mocks/mock_synonym_set_connection.h +++ b/google/cloud/contentwarehouse/v1/mocks/mock_synonym_set_connection.h @@ -78,6 +78,10 @@ class MockSynonymSetServiceConnection ListSynonymSets, (google::cloud::contentwarehouse::v1::ListSynonymSetsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/contentwarehouse/v1/pipeline_client.cc b/google/cloud/contentwarehouse/v1/pipeline_client.cc index d442d68e8adef..d4c6b33523caa 100644 --- a/google/cloud/contentwarehouse/v1/pipeline_client.cc +++ b/google/cloud/contentwarehouse/v1/pipeline_client.cc @@ -71,6 +71,20 @@ PipelineServiceClient::RunPipeline( return connection_->RunPipeline(operation); } +StatusOr PipelineServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr PipelineServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace contentwarehouse_v1 } // namespace cloud diff --git a/google/cloud/contentwarehouse/v1/pipeline_client.h b/google/cloud/contentwarehouse/v1/pipeline_client.h index f6a2e7ef800c4..42325e265f842 100644 --- a/google/cloud/contentwarehouse/v1/pipeline_client.h +++ b/google/cloud/contentwarehouse/v1/pipeline_client.h @@ -203,6 +203,66 @@ class PipelineServiceClient { RunPipeline(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/contentwarehouse/v1/pipeline_connection.cc b/google/cloud/contentwarehouse/v1/pipeline_connection.cc index 6206f4c52b519..ff03d6313f989 100644 --- a/google/cloud/contentwarehouse/v1/pipeline_connection.cc +++ b/google/cloud/contentwarehouse/v1/pipeline_connection.cc @@ -59,6 +59,12 @@ PipelineServiceConnection::RunPipeline(google::longrunning::Operation const&) { Status(StatusCode::kUnimplemented, "not implemented")); } +StatusOr +PipelineServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakePipelineServiceConnection( Options options) { internal::CheckExpectedOptions> RunPipeline(google::longrunning::Operation const& operation); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/contentwarehouse/v1/pipeline_connection_idempotency_policy.cc b/google/cloud/contentwarehouse/v1/pipeline_connection_idempotency_policy.cc index d45f3fdefef64..7291da5cfc56c 100644 --- a/google/cloud/contentwarehouse/v1/pipeline_connection_idempotency_policy.cc +++ b/google/cloud/contentwarehouse/v1/pipeline_connection_idempotency_policy.cc @@ -39,6 +39,11 @@ Idempotency PipelineServiceConnectionIdempotencyPolicy::RunPipeline( return Idempotency::kNonIdempotent; } +Idempotency PipelineServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultPipelineServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/contentwarehouse/v1/pipeline_connection_idempotency_policy.h b/google/cloud/contentwarehouse/v1/pipeline_connection_idempotency_policy.h index 36a2b06ec2865..13ceb0191e746 100644 --- a/google/cloud/contentwarehouse/v1/pipeline_connection_idempotency_policy.h +++ b/google/cloud/contentwarehouse/v1/pipeline_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -39,6 +40,9 @@ class PipelineServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency RunPipeline( google::cloud::contentwarehouse::v1::RunPipelineRequest const& request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/contentwarehouse/v1/rule_set_client.cc b/google/cloud/contentwarehouse/v1/rule_set_client.cc index 6e59c73d1511f..bce2c88de040d 100644 --- a/google/cloud/contentwarehouse/v1/rule_set_client.cc +++ b/google/cloud/contentwarehouse/v1/rule_set_client.cc @@ -119,6 +119,20 @@ RuleSetServiceClient::ListRuleSets( return connection_->ListRuleSets(std::move(request)); } +StatusOr RuleSetServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr RuleSetServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace contentwarehouse_v1 } // namespace cloud diff --git a/google/cloud/contentwarehouse/v1/rule_set_client.h b/google/cloud/contentwarehouse/v1/rule_set_client.h index fdeac860a0012..b8b81c3424ab0 100644 --- a/google/cloud/contentwarehouse/v1/rule_set_client.h +++ b/google/cloud/contentwarehouse/v1/rule_set_client.h @@ -392,6 +392,66 @@ class RuleSetServiceClient { google::cloud::contentwarehouse::v1::ListRuleSetsRequest request, Options opts = {}); + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/contentwarehouse/v1/rule_set_connection.cc b/google/cloud/contentwarehouse/v1/rule_set_connection.cc index c00e217aadca9..327863fe39dea 100644 --- a/google/cloud/contentwarehouse/v1/rule_set_connection.cc +++ b/google/cloud/contentwarehouse/v1/rule_set_connection.cc @@ -69,6 +69,11 @@ RuleSetServiceConnection::ListRuleSets( StreamRange>(); } +StatusOr RuleSetServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeRuleSetServiceConnection( Options options) { internal::CheckExpectedOptions ListRuleSets( google::cloud::contentwarehouse::v1::ListRuleSetsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/contentwarehouse/v1/rule_set_connection_idempotency_policy.cc b/google/cloud/contentwarehouse/v1/rule_set_connection_idempotency_policy.cc index db9ffe5b1de32..d13476f8ad3af 100644 --- a/google/cloud/contentwarehouse/v1/rule_set_connection_idempotency_policy.cc +++ b/google/cloud/contentwarehouse/v1/rule_set_connection_idempotency_policy.cc @@ -59,6 +59,11 @@ Idempotency RuleSetServiceConnectionIdempotencyPolicy::ListRuleSets( return Idempotency::kIdempotent; } +Idempotency RuleSetServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultRuleSetServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/contentwarehouse/v1/rule_set_connection_idempotency_policy.h b/google/cloud/contentwarehouse/v1/rule_set_connection_idempotency_policy.h index 7192cd068aa7d..5646146b64a6e 100644 --- a/google/cloud/contentwarehouse/v1/rule_set_connection_idempotency_policy.h +++ b/google/cloud/contentwarehouse/v1/rule_set_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,9 @@ class RuleSetServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListRuleSets( google::cloud::contentwarehouse::v1::ListRuleSetsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/contentwarehouse/v1/synonym_set_client.cc b/google/cloud/contentwarehouse/v1/synonym_set_client.cc index 573461499941c..8e0b40894fe1d 100644 --- a/google/cloud/contentwarehouse/v1/synonym_set_client.cc +++ b/google/cloud/contentwarehouse/v1/synonym_set_client.cc @@ -120,6 +120,20 @@ SynonymSetServiceClient::ListSynonymSets( return connection_->ListSynonymSets(std::move(request)); } +StatusOr SynonymSetServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr SynonymSetServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace contentwarehouse_v1 } // namespace cloud diff --git a/google/cloud/contentwarehouse/v1/synonym_set_client.h b/google/cloud/contentwarehouse/v1/synonym_set_client.h index 30f2d4ed570f4..ed65e26ff3b74 100644 --- a/google/cloud/contentwarehouse/v1/synonym_set_client.h +++ b/google/cloud/contentwarehouse/v1/synonym_set_client.h @@ -408,6 +408,66 @@ class SynonymSetServiceClient { google::cloud::contentwarehouse::v1::ListSynonymSetsRequest request, Options opts = {}); + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/contentwarehouse/v1/synonym_set_connection.cc b/google/cloud/contentwarehouse/v1/synonym_set_connection.cc index 866fc016b2433..42eed9602fb3f 100644 --- a/google/cloud/contentwarehouse/v1/synonym_set_connection.cc +++ b/google/cloud/contentwarehouse/v1/synonym_set_connection.cc @@ -69,6 +69,12 @@ SynonymSetServiceConnection::ListSynonymSets( StreamRange>(); } +StatusOr +SynonymSetServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSynonymSetServiceConnection( Options options) { internal::CheckExpectedOptions ListSynonymSets( google::cloud::contentwarehouse::v1::ListSynonymSetsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/contentwarehouse/v1/synonym_set_connection_idempotency_policy.cc b/google/cloud/contentwarehouse/v1/synonym_set_connection_idempotency_policy.cc index d64fe11914191..e82ea3bdb13ad 100644 --- a/google/cloud/contentwarehouse/v1/synonym_set_connection_idempotency_policy.cc +++ b/google/cloud/contentwarehouse/v1/synonym_set_connection_idempotency_policy.cc @@ -59,6 +59,11 @@ Idempotency SynonymSetServiceConnectionIdempotencyPolicy::ListSynonymSets( return Idempotency::kIdempotent; } +Idempotency SynonymSetServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultSynonymSetServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/contentwarehouse/v1/synonym_set_connection_idempotency_policy.h b/google/cloud/contentwarehouse/v1/synonym_set_connection_idempotency_policy.h index 8149c93e7885a..05e669f491467 100644 --- a/google/cloud/contentwarehouse/v1/synonym_set_connection_idempotency_policy.h +++ b/google/cloud/contentwarehouse/v1/synonym_set_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,9 @@ class SynonymSetServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListSynonymSets( google::cloud::contentwarehouse::v1::ListSynonymSetsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr 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/lineage/v1/internal/lineage_auth_decorator.cc b/google/cloud/datacatalog/lineage/v1/internal/lineage_auth_decorator.cc index 54ed8bfb369ef..f599e0e94e085 100644 --- a/google/cloud/datacatalog/lineage/v1/internal/lineage_auth_decorator.cc +++ b/google/cloud/datacatalog/lineage/v1/internal/lineage_auth_decorator.cc @@ -231,6 +231,39 @@ LineageAuth::BatchSearchLinkProcesses( return child_->BatchSearchLinkProcesses(context, options, request); } +StatusOr +LineageAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr LineageAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status LineageAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status LineageAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + future> LineageAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/datacatalog/lineage/v1/internal/lineage_auth_decorator.h b/google/cloud/datacatalog/lineage/v1/internal/lineage_auth_decorator.h index 16d3e79ba8b37..0cc484afb1941 100644 --- a/google/cloud/datacatalog/lineage/v1/internal/lineage_auth_decorator.h +++ b/google/cloud/datacatalog/lineage/v1/internal/lineage_auth_decorator.h @@ -146,6 +146,22 @@ class LineageAuth : public LineageStub { google::cloud::datacatalog::lineage::v1:: BatchSearchLinkProcessesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/datacatalog/lineage/v1/internal/lineage_connection_impl.cc b/google/cloud/datacatalog/lineage/v1/internal/lineage_connection_impl.cc index 40fccb577b4cf..300e4cc4e8019 100644 --- a/google/cloud/datacatalog/lineage/v1/internal/lineage_connection_impl.cc +++ b/google/cloud/datacatalog/lineage/v1/internal/lineage_connection_impl.cc @@ -589,6 +589,78 @@ LineageConnectionImpl::BatchSearchLinkProcesses( }); } +StreamRange +LineageConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr LineageConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status LineageConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status LineageConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace datacatalog_lineage_v1_internal } // namespace cloud diff --git a/google/cloud/datacatalog/lineage/v1/internal/lineage_connection_impl.h b/google/cloud/datacatalog/lineage/v1/internal/lineage_connection_impl.h index 7d106de93f205..baa52e9b49665 100644 --- a/google/cloud/datacatalog/lineage/v1/internal/lineage_connection_impl.h +++ b/google/cloud/datacatalog/lineage/v1/internal/lineage_connection_impl.h @@ -142,6 +142,18 @@ class LineageConnectionImpl : public datacatalog_lineage_v1::LineageConnection { google::cloud::datacatalog::lineage::v1::BatchSearchLinkProcessesRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/datacatalog/lineage/v1/internal/lineage_logging_decorator.cc b/google/cloud/datacatalog/lineage/v1/internal/lineage_logging_decorator.cc index c6e09139cd08a..f9e9269144195 100644 --- a/google/cloud/datacatalog/lineage/v1/internal/lineage_logging_decorator.cc +++ b/google/cloud/datacatalog/lineage/v1/internal/lineage_logging_decorator.cc @@ -307,6 +307,51 @@ LineageLogging::BatchSearchLinkProcesses( context, options, request, __func__, tracing_options_); } +StatusOr +LineageLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr LineageLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status LineageLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status LineageLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> LineageLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/datacatalog/lineage/v1/internal/lineage_logging_decorator.h b/google/cloud/datacatalog/lineage/v1/internal/lineage_logging_decorator.h index d9fedba61d3a3..419139faa9b8b 100644 --- a/google/cloud/datacatalog/lineage/v1/internal/lineage_logging_decorator.h +++ b/google/cloud/datacatalog/lineage/v1/internal/lineage_logging_decorator.h @@ -146,6 +146,22 @@ class LineageLogging : public LineageStub { google::cloud::datacatalog::lineage::v1:: BatchSearchLinkProcessesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/datacatalog/lineage/v1/internal/lineage_metadata_decorator.cc b/google/cloud/datacatalog/lineage/v1/internal/lineage_metadata_decorator.cc index b59ee60129ba1..dc5f60ecd18c9 100644 --- a/google/cloud/datacatalog/lineage/v1/internal/lineage_metadata_decorator.cc +++ b/google/cloud/datacatalog/lineage/v1/internal/lineage_metadata_decorator.cc @@ -233,6 +233,39 @@ LineageMetadata::BatchSearchLinkProcesses( return child_->BatchSearchLinkProcesses(context, options, request); } +StatusOr +LineageMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr LineageMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status LineageMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status LineageMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + future> LineageMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/datacatalog/lineage/v1/internal/lineage_metadata_decorator.h b/google/cloud/datacatalog/lineage/v1/internal/lineage_metadata_decorator.h index 071b0a257b208..d8981eb24fb4e 100644 --- a/google/cloud/datacatalog/lineage/v1/internal/lineage_metadata_decorator.h +++ b/google/cloud/datacatalog/lineage/v1/internal/lineage_metadata_decorator.h @@ -146,6 +146,22 @@ class LineageMetadata : public LineageStub { google::cloud::datacatalog::lineage::v1:: BatchSearchLinkProcessesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/datacatalog/lineage/v1/internal/lineage_stub.cc b/google/cloud/datacatalog/lineage/v1/internal/lineage_stub.cc index 0f9ae5bc7b622..9631b253523fa 100644 --- a/google/cloud/datacatalog/lineage/v1/internal/lineage_stub.cc +++ b/google/cloud/datacatalog/lineage/v1/internal/lineage_stub.cc @@ -289,6 +289,51 @@ DefaultLineageStub::BatchSearchLinkProcesses( return response; } +StatusOr +DefaultLineageStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultLineageStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultLineageStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultLineageStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + future> DefaultLineageStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/datacatalog/lineage/v1/internal/lineage_stub.h b/google/cloud/datacatalog/lineage/v1/internal/lineage_stub.h index c196bfb1f274f..7bd4112b1af98 100644 --- a/google/cloud/datacatalog/lineage/v1/internal/lineage_stub.h +++ b/google/cloud/datacatalog/lineage/v1/internal/lineage_stub.h @@ -149,6 +149,22 @@ class LineageStub { google::cloud::datacatalog::lineage::v1:: BatchSearchLinkProcessesRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -168,9 +184,13 @@ class DefaultLineageStub : public LineageStub { std::unique_ptr< google::cloud::datacatalog::lineage::v1::Lineage::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr @@ -279,6 +299,22 @@ class DefaultLineageStub : public LineageStub { google::cloud::datacatalog::lineage::v1:: BatchSearchLinkProcessesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -295,6 +331,8 @@ class DefaultLineageStub : public LineageStub { std::unique_ptr< google::cloud::datacatalog::lineage::v1::Lineage::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/datacatalog/lineage/v1/internal/lineage_stub_factory.cc b/google/cloud/datacatalog/lineage/v1/internal/lineage_stub_factory.cc index ce5c421a12ee4..51aace160fe3b 100644 --- a/google/cloud/datacatalog/lineage/v1/internal/lineage_stub_factory.cc +++ b/google/cloud/datacatalog/lineage/v1/internal/lineage_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 CreateDefaultLineageStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::datacatalog::lineage::v1::Lineage::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/datacatalog/lineage/v1/internal/lineage_tracing_connection.cc b/google/cloud/datacatalog/lineage/v1/internal/lineage_tracing_connection.cc index 06fdc25e4dacf..a4b196313f0f3 100644 --- a/google/cloud/datacatalog/lineage/v1/internal/lineage_tracing_connection.cc +++ b/google/cloud/datacatalog/lineage/v1/internal/lineage_tracing_connection.cc @@ -247,6 +247,41 @@ LineageTracingConnection::BatchSearchLinkProcesses( std::move(sr)); } +StreamRange +LineageTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "datacatalog_lineage_v1::LineageConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr LineageTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "datacatalog_lineage_v1::LineageConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status LineageTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "datacatalog_lineage_v1::LineageConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status LineageTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "datacatalog_lineage_v1::LineageConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/datacatalog/lineage/v1/internal/lineage_tracing_connection.h b/google/cloud/datacatalog/lineage/v1/internal/lineage_tracing_connection.h index 154402699ff3b..2f22589aaed79 100644 --- a/google/cloud/datacatalog/lineage/v1/internal/lineage_tracing_connection.h +++ b/google/cloud/datacatalog/lineage/v1/internal/lineage_tracing_connection.h @@ -131,6 +131,18 @@ class LineageTracingConnection google::cloud::datacatalog::lineage::v1::BatchSearchLinkProcessesRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/datacatalog/lineage/v1/internal/lineage_tracing_stub.cc b/google/cloud/datacatalog/lineage/v1/internal/lineage_tracing_stub.cc index dfcdf4c8921fb..81b5722aa09b8 100644 --- a/google/cloud/datacatalog/lineage/v1/internal/lineage_tracing_stub.cc +++ b/google/cloud/datacatalog/lineage/v1/internal/lineage_tracing_stub.cc @@ -278,6 +278,51 @@ LineageTracingStub::BatchSearchLinkProcesses( child_->BatchSearchLinkProcesses(context, options, request)); } +StatusOr +LineageTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.datacatalog.lineage.v1.Lineage", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr LineageTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.datacatalog.lineage.v1.Lineage", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status LineageTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.datacatalog.lineage.v1.Lineage", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status LineageTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.datacatalog.lineage.v1.Lineage", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + future> LineageTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/datacatalog/lineage/v1/internal/lineage_tracing_stub.h b/google/cloud/datacatalog/lineage/v1/internal/lineage_tracing_stub.h index 02bd26a34b733..a8d99d6fd2115 100644 --- a/google/cloud/datacatalog/lineage/v1/internal/lineage_tracing_stub.h +++ b/google/cloud/datacatalog/lineage/v1/internal/lineage_tracing_stub.h @@ -145,6 +145,22 @@ class LineageTracingStub : public LineageStub { google::cloud::datacatalog::lineage::v1:: BatchSearchLinkProcessesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/datacatalog/lineage/v1/lineage_client.cc b/google/cloud/datacatalog/lineage/v1/lineage_client.cc index a1eebc560bd80..37f5b8c2cf8cb 100644 --- a/google/cloud/datacatalog/lineage/v1/lineage_client.cc +++ b/google/cloud/datacatalog/lineage/v1/lineage_client.cc @@ -360,6 +360,61 @@ LineageClient::BatchSearchLinkProcesses( return connection_->BatchSearchLinkProcesses(std::move(request)); } +StreamRange LineageClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange LineageClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr LineageClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr LineageClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status LineageClient::DeleteOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status LineageClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status LineageClient::CancelOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status LineageClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace datacatalog_lineage_v1 } // namespace cloud diff --git a/google/cloud/datacatalog/lineage/v1/lineage_client.h b/google/cloud/datacatalog/lineage/v1/lineage_client.h index f29bda561753e..f326b9c357a59 100644 --- a/google/cloud/datacatalog/lineage/v1/lineage_client.h +++ b/google/cloud/datacatalog/lineage/v1/lineage_client.h @@ -1257,6 +1257,286 @@ class LineageClient { request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/datacatalog/lineage/v1/lineage_connection.cc b/google/cloud/datacatalog/lineage/v1/lineage_connection.cc index b7d2e19894479..4e1b5ae877136 100644 --- a/google/cloud/datacatalog/lineage/v1/lineage_connection.cc +++ b/google/cloud/datacatalog/lineage/v1/lineage_connection.cc @@ -183,6 +183,28 @@ LineageConnection::BatchSearchLinkProcesses( StreamRange>(); } +StreamRange LineageConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr LineageConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status LineageConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status LineageConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeLineageConnection(Options options) { internal::CheckExpectedOptions ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/datacatalog/lineage/v1/lineage_connection_idempotency_policy.cc b/google/cloud/datacatalog/lineage/v1/lineage_connection_idempotency_policy.cc index 7f2ed5298a5ee..0a43ce9e935eb 100644 --- a/google/cloud/datacatalog/lineage/v1/lineage_connection_idempotency_policy.cc +++ b/google/cloud/datacatalog/lineage/v1/lineage_connection_idempotency_policy.cc @@ -122,6 +122,26 @@ Idempotency LineageConnectionIdempotencyPolicy::BatchSearchLinkProcesses( return Idempotency::kNonIdempotent; } +Idempotency LineageConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency LineageConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency LineageConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency LineageConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultLineageConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/datacatalog/lineage/v1/lineage_connection_idempotency_policy.h b/google/cloud/datacatalog/lineage/v1/lineage_connection_idempotency_policy.h index 6afbef633f135..7140a000c207c 100644 --- a/google/cloud/datacatalog/lineage/v1/lineage_connection_idempotency_policy.h +++ b/google/cloud/datacatalog/lineage/v1/lineage_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -96,6 +97,18 @@ class LineageConnectionIdempotencyPolicy { virtual google::cloud::Idempotency BatchSearchLinkProcesses( google::cloud::datacatalog::lineage::v1::BatchSearchLinkProcessesRequest request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/datacatalog/lineage/v1/mocks/mock_lineage_connection.h b/google/cloud/datacatalog/lineage/v1/mocks/mock_lineage_connection.h index 39729e77b916a..ee9efb9ea7f87 100644 --- a/google/cloud/datacatalog/lineage/v1/mocks/mock_lineage_connection.h +++ b/google/cloud/datacatalog/lineage/v1/mocks/mock_lineage_connection.h @@ -221,6 +221,21 @@ class MockLineageConnection : public datacatalog_lineage_v1::LineageConnection { (google::cloud::datacatalog::lineage::v1::BatchSearchLinkProcessesRequest request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/datacatalog/v1/data_catalog_client.cc b/google/cloud/datacatalog/v1/data_catalog_client.cc index 14479579c2844..f1f65ed79aaa3 100644 --- a/google/cloud/datacatalog/v1/data_catalog_client.cc +++ b/google/cloud/datacatalog/v1/data_catalog_client.cc @@ -687,6 +687,63 @@ DataCatalogClient::ImportEntries( return connection_->ImportEntries(operation); } +StreamRange DataCatalogClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange DataCatalogClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr DataCatalogClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr DataCatalogClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status DataCatalogClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status DataCatalogClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status DataCatalogClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status DataCatalogClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace datacatalog_v1 } // namespace cloud diff --git a/google/cloud/datacatalog/v1/data_catalog_client.h b/google/cloud/datacatalog/v1/data_catalog_client.h index 87cda923be670..a1771582a8c37 100644 --- a/google/cloud/datacatalog/v1/data_catalog_client.h +++ b/google/cloud/datacatalog/v1/data_catalog_client.h @@ -2731,6 +2731,286 @@ class DataCatalogClient { ImportEntries(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/datacatalog/v1/data_catalog_connection.cc b/google/cloud/datacatalog/v1/data_catalog_connection.cc index d0160507d7233..42b7eee9adc19 100644 --- a/google/cloud/datacatalog/v1/data_catalog_connection.cc +++ b/google/cloud/datacatalog/v1/data_catalog_connection.cc @@ -271,6 +271,29 @@ DataCatalogConnection::ImportEntries(google::longrunning::Operation const&) { Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +DataCatalogConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr DataCatalogConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DataCatalogConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DataCatalogConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDataCatalogConnection( Options options) { internal::CheckExpectedOptions> ImportEntries(google::longrunning::Operation const& operation); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/datacatalog/v1/data_catalog_connection_idempotency_policy.cc b/google/cloud/datacatalog/v1/data_catalog_connection_idempotency_policy.cc index 165127f94a3b0..7967a35658832 100644 --- a/google/cloud/datacatalog/v1/data_catalog_connection_idempotency_policy.cc +++ b/google/cloud/datacatalog/v1/data_catalog_connection_idempotency_policy.cc @@ -207,6 +207,26 @@ Idempotency DataCatalogConnectionIdempotencyPolicy::ImportEntries( return Idempotency::kNonIdempotent; } +Idempotency DataCatalogConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DataCatalogConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DataCatalogConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency DataCatalogConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultDataCatalogConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/datacatalog/v1/data_catalog_connection_idempotency_policy.h b/google/cloud/datacatalog/v1/data_catalog_connection_idempotency_policy.h index 875dea09cfb7a..f240601625920 100644 --- a/google/cloud/datacatalog/v1/data_catalog_connection_idempotency_policy.h +++ b/google/cloud/datacatalog/v1/data_catalog_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -144,6 +145,18 @@ class DataCatalogConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ImportEntries( google::cloud::datacatalog::v1::ImportEntriesRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/datacatalog/v1/internal/data_catalog_auth_decorator.cc b/google/cloud/datacatalog/v1/internal/data_catalog_auth_decorator.cc index 1c2df4a7adccc..7e1372d20addd 100644 --- a/google/cloud/datacatalog/v1/internal/data_catalog_auth_decorator.cc +++ b/google/cloud/datacatalog/v1/internal/data_catalog_auth_decorator.cc @@ -367,6 +367,39 @@ StatusOr DataCatalogAuth::ImportEntries( return child_->ImportEntries(context, options, request); } +StatusOr +DataCatalogAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr DataCatalogAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status DataCatalogAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status DataCatalogAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + future> DataCatalogAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/datacatalog/v1/internal/data_catalog_auth_decorator.h b/google/cloud/datacatalog/v1/internal/data_catalog_auth_decorator.h index fbb8043afc712..8b359856ee1bb 100644 --- a/google/cloud/datacatalog/v1/internal/data_catalog_auth_decorator.h +++ b/google/cloud/datacatalog/v1/internal/data_catalog_auth_decorator.h @@ -217,6 +217,22 @@ class DataCatalogAuth : public DataCatalogStub { google::cloud::datacatalog::v1::ImportEntriesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/datacatalog/v1/internal/data_catalog_connection_impl.cc b/google/cloud/datacatalog/v1/internal/data_catalog_connection_impl.cc index 6e737595e3d3a..c08ca03c5f1c1 100644 --- a/google/cloud/datacatalog/v1/internal/data_catalog_connection_impl.cc +++ b/google/cloud/datacatalog/v1/internal/data_catalog_connection_impl.cc @@ -801,6 +801,79 @@ DataCatalogConnectionImpl::ImportEntries( polling_policy(*current), __func__); } +StreamRange +DataCatalogConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DataCatalogConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DataCatalogConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DataCatalogConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace datacatalog_v1_internal } // namespace cloud diff --git a/google/cloud/datacatalog/v1/internal/data_catalog_connection_impl.h b/google/cloud/datacatalog/v1/internal/data_catalog_connection_impl.h index e3be7751ad775..f49d3d1a7ec69 100644 --- a/google/cloud/datacatalog/v1/internal/data_catalog_connection_impl.h +++ b/google/cloud/datacatalog/v1/internal/data_catalog_connection_impl.h @@ -195,6 +195,18 @@ class DataCatalogConnectionImpl : public datacatalog_v1::DataCatalogConnection { future> ImportEntries(google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/datacatalog/v1/internal/data_catalog_logging_decorator.cc b/google/cloud/datacatalog/v1/internal/data_catalog_logging_decorator.cc index aa33881b920e4..6a07077f90e5d 100644 --- a/google/cloud/datacatalog/v1/internal/data_catalog_logging_decorator.cc +++ b/google/cloud/datacatalog/v1/internal/data_catalog_logging_decorator.cc @@ -501,6 +501,51 @@ StatusOr DataCatalogLogging::ImportEntries( context, options, request, __func__, tracing_options_); } +StatusOr +DataCatalogLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DataCatalogLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DataCatalogLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DataCatalogLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> DataCatalogLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/datacatalog/v1/internal/data_catalog_logging_decorator.h b/google/cloud/datacatalog/v1/internal/data_catalog_logging_decorator.h index 7f30e6cb68ee3..7556432639f58 100644 --- a/google/cloud/datacatalog/v1/internal/data_catalog_logging_decorator.h +++ b/google/cloud/datacatalog/v1/internal/data_catalog_logging_decorator.h @@ -217,6 +217,22 @@ class DataCatalogLogging : public DataCatalogStub { google::cloud::datacatalog::v1::ImportEntriesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/datacatalog/v1/internal/data_catalog_metadata_decorator.cc b/google/cloud/datacatalog/v1/internal/data_catalog_metadata_decorator.cc index fca04f7eddbaa..8ee56dfec8eae 100644 --- a/google/cloud/datacatalog/v1/internal/data_catalog_metadata_decorator.cc +++ b/google/cloud/datacatalog/v1/internal/data_catalog_metadata_decorator.cc @@ -372,6 +372,39 @@ StatusOr DataCatalogMetadata::ImportEntries( return child_->ImportEntries(context, options, request); } +StatusOr +DataCatalogMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr DataCatalogMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status DataCatalogMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status DataCatalogMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + future> DataCatalogMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/datacatalog/v1/internal/data_catalog_metadata_decorator.h b/google/cloud/datacatalog/v1/internal/data_catalog_metadata_decorator.h index fdfdd8280d06a..78d9a121b092e 100644 --- a/google/cloud/datacatalog/v1/internal/data_catalog_metadata_decorator.h +++ b/google/cloud/datacatalog/v1/internal/data_catalog_metadata_decorator.h @@ -217,6 +217,22 @@ class DataCatalogMetadata : public DataCatalogStub { google::cloud::datacatalog::v1::ImportEntriesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/datacatalog/v1/internal/data_catalog_stub.cc b/google/cloud/datacatalog/v1/internal/data_catalog_stub.cc index 29da098f887ca..8ecaa50ea0eb2 100644 --- a/google/cloud/datacatalog/v1/internal/data_catalog_stub.cc +++ b/google/cloud/datacatalog/v1/internal/data_catalog_stub.cc @@ -476,6 +476,51 @@ StatusOr DefaultDataCatalogStub::ImportEntries( return response; } +StatusOr +DefaultDataCatalogStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultDataCatalogStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultDataCatalogStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultDataCatalogStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + future> DefaultDataCatalogStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/datacatalog/v1/internal/data_catalog_stub.h b/google/cloud/datacatalog/v1/internal/data_catalog_stub.h index 2f0ddd39b22dd..a601fafcc1dcc 100644 --- a/google/cloud/datacatalog/v1/internal/data_catalog_stub.h +++ b/google/cloud/datacatalog/v1/internal/data_catalog_stub.h @@ -212,6 +212,22 @@ class DataCatalogStub { grpc::ClientContext& context, Options options, google::cloud::datacatalog::v1::ImportEntriesRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -231,9 +247,13 @@ class DefaultDataCatalogStub : public DataCatalogStub { std::unique_ptr< google::cloud::datacatalog::v1::DataCatalog::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr SearchCatalog( grpc::ClientContext& context, Options const& options, @@ -413,6 +433,22 @@ class DefaultDataCatalogStub : public DataCatalogStub { google::cloud::datacatalog::v1::ImportEntriesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -428,6 +464,8 @@ class DefaultDataCatalogStub : public DataCatalogStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/datacatalog/v1/internal/data_catalog_stub_factory.cc b/google/cloud/datacatalog/v1/internal/data_catalog_stub_factory.cc index 700aaced778e4..87cecb71d33d5 100644 --- a/google/cloud/datacatalog/v1/internal/data_catalog_stub_factory.cc +++ b/google/cloud/datacatalog/v1/internal/data_catalog_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 CreateDefaultDataCatalogStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::datacatalog::v1::DataCatalog::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/datacatalog/v1/internal/data_catalog_tracing_connection.cc b/google/cloud/datacatalog/v1/internal/data_catalog_tracing_connection.cc index 80a412fdca9cc..a36e949f4e8e9 100644 --- a/google/cloud/datacatalog/v1/internal/data_catalog_tracing_connection.cc +++ b/google/cloud/datacatalog/v1/internal/data_catalog_tracing_connection.cc @@ -386,6 +386,42 @@ DataCatalogTracingConnection::ImportEntries( return internal::EndSpan(std::move(span), child_->ImportEntries(operation)); } +StreamRange +DataCatalogTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "datacatalog_v1::DataCatalogConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DataCatalogTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("datacatalog_v1::DataCatalogConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status DataCatalogTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "datacatalog_v1::DataCatalogConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status DataCatalogTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "datacatalog_v1::DataCatalogConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/datacatalog/v1/internal/data_catalog_tracing_connection.h b/google/cloud/datacatalog/v1/internal/data_catalog_tracing_connection.h index b4687107eaa19..cadd0e2a51aaa 100644 --- a/google/cloud/datacatalog/v1/internal/data_catalog_tracing_connection.h +++ b/google/cloud/datacatalog/v1/internal/data_catalog_tracing_connection.h @@ -184,6 +184,18 @@ class DataCatalogTracingConnection future> ImportEntries(google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/datacatalog/v1/internal/data_catalog_tracing_stub.cc b/google/cloud/datacatalog/v1/internal/data_catalog_tracing_stub.cc index b21cda2050f4c..2799945a4fd22 100644 --- a/google/cloud/datacatalog/v1/internal/data_catalog_tracing_stub.cc +++ b/google/cloud/datacatalog/v1/internal/data_catalog_tracing_stub.cc @@ -467,6 +467,51 @@ StatusOr DataCatalogTracingStub::ImportEntries( child_->ImportEntries(context, options, request)); } +StatusOr +DataCatalogTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.datacatalog.v1.DataCatalog", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr DataCatalogTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.datacatalog.v1.DataCatalog", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status DataCatalogTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.datacatalog.v1.DataCatalog", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status DataCatalogTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.datacatalog.v1.DataCatalog", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + future> DataCatalogTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/datacatalog/v1/internal/data_catalog_tracing_stub.h b/google/cloud/datacatalog/v1/internal/data_catalog_tracing_stub.h index 9d656cac153f1..9768d95493e47 100644 --- a/google/cloud/datacatalog/v1/internal/data_catalog_tracing_stub.h +++ b/google/cloud/datacatalog/v1/internal/data_catalog_tracing_stub.h @@ -216,6 +216,22 @@ class DataCatalogTracingStub : public DataCatalogStub { google::cloud::datacatalog::v1::ImportEntriesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_auth_decorator.cc b/google/cloud/datacatalog/v1/internal/policy_tag_manager_auth_decorator.cc index 1484daebe35c8..bfadd7de1cc6c 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_auth_decorator.cc +++ b/google/cloud/datacatalog/v1/internal/policy_tag_manager_auth_decorator.cc @@ -144,6 +144,39 @@ PolicyTagManagerAuth::TestIamPermissions( return child_->TestIamPermissions(context, options, request); } +StatusOr +PolicyTagManagerAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr PolicyTagManagerAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status PolicyTagManagerAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status PolicyTagManagerAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace datacatalog_v1_internal } // namespace cloud diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_auth_decorator.h b/google/cloud/datacatalog/v1/internal/policy_tag_manager_auth_decorator.h index ad3a8499d2842..5173c57076629 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_auth_decorator.h +++ b/google/cloud/datacatalog/v1/internal/policy_tag_manager_auth_decorator.h @@ -100,6 +100,22 @@ class PolicyTagManagerAuth : public PolicyTagManagerStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_connection_impl.cc b/google/cloud/datacatalog/v1/internal/policy_tag_manager_connection_impl.cc index 3f299e2c2ff0a..8098ee6a0bb54 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_connection_impl.cc +++ b/google/cloud/datacatalog/v1/internal/policy_tag_manager_connection_impl.cc @@ -287,6 +287,79 @@ PolicyTagManagerConnectionImpl::TestIamPermissions( *current, request, __func__); } +StreamRange +PolicyTagManagerConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +PolicyTagManagerConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status PolicyTagManagerConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status PolicyTagManagerConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace datacatalog_v1_internal } // namespace cloud diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_connection_impl.h b/google/cloud/datacatalog/v1/internal/policy_tag_manager_connection_impl.h index 3c49d320e528a..a80c839c94140 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_connection_impl.h +++ b/google/cloud/datacatalog/v1/internal/policy_tag_manager_connection_impl.h @@ -96,6 +96,18 @@ class PolicyTagManagerConnectionImpl StatusOr TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_logging_decorator.cc b/google/cloud/datacatalog/v1/internal/policy_tag_manager_logging_decorator.cc index d9ba49e73f931..239a8b71f486b 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_logging_decorator.cc +++ b/google/cloud/datacatalog/v1/internal/policy_tag_manager_logging_decorator.cc @@ -197,6 +197,51 @@ PolicyTagManagerLogging::TestIamPermissions( context, options, request, __func__, tracing_options_); } +StatusOr +PolicyTagManagerLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr PolicyTagManagerLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status PolicyTagManagerLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status PolicyTagManagerLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace datacatalog_v1_internal } // namespace cloud diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_logging_decorator.h b/google/cloud/datacatalog/v1/internal/policy_tag_manager_logging_decorator.h index 2c4ab384a348e..71d9a7d2fdaad 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_logging_decorator.h +++ b/google/cloud/datacatalog/v1/internal/policy_tag_manager_logging_decorator.h @@ -100,6 +100,22 @@ class PolicyTagManagerLogging : public PolicyTagManagerStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_metadata_decorator.cc b/google/cloud/datacatalog/v1/internal/policy_tag_manager_metadata_decorator.cc index 315b50b8f046a..a6d9b68fb98d2 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_metadata_decorator.cc +++ b/google/cloud/datacatalog/v1/internal/policy_tag_manager_metadata_decorator.cc @@ -162,6 +162,39 @@ PolicyTagManagerMetadata::TestIamPermissions( return child_->TestIamPermissions(context, options, request); } +StatusOr +PolicyTagManagerMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr PolicyTagManagerMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status PolicyTagManagerMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status PolicyTagManagerMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + void PolicyTagManagerMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_metadata_decorator.h b/google/cloud/datacatalog/v1/internal/policy_tag_manager_metadata_decorator.h index 1e10e8d937775..87cc73c88207b 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_metadata_decorator.h +++ b/google/cloud/datacatalog/v1/internal/policy_tag_manager_metadata_decorator.h @@ -101,6 +101,22 @@ class PolicyTagManagerMetadata : public PolicyTagManagerStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_auth_decorator.cc b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_auth_decorator.cc index d62d4fc293884..bd618b48985ac 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_auth_decorator.cc +++ b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_auth_decorator.cc @@ -58,6 +58,40 @@ PolicyTagManagerSerializationAuth::ExportTaxonomies( return child_->ExportTaxonomies(context, options, request); } +StatusOr +PolicyTagManagerSerializationAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +PolicyTagManagerSerializationAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status PolicyTagManagerSerializationAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status PolicyTagManagerSerializationAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace datacatalog_v1_internal } // namespace cloud diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_auth_decorator.h b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_auth_decorator.h index e56f3505ce785..bab43aac659c5 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_auth_decorator.h +++ b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_auth_decorator.h @@ -56,6 +56,22 @@ class PolicyTagManagerSerializationAuth google::cloud::datacatalog::v1::ExportTaxonomiesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_connection_impl.cc b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_connection_impl.cc index 22d8c3214575c..fe44928774b08 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_connection_impl.cc +++ b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_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 @@ -113,6 +114,80 @@ PolicyTagManagerSerializationConnectionImpl::ExportTaxonomies( *current, request, __func__); } +StreamRange +PolicyTagManagerSerializationConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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< + datacatalog_v1::PolicyTagManagerSerializationRetryPolicy>( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +PolicyTagManagerSerializationConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status PolicyTagManagerSerializationConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status PolicyTagManagerSerializationConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace datacatalog_v1_internal } // namespace cloud diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_connection_impl.h b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_connection_impl.h index 85e4609a98686..23e02504d8b7e 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_connection_impl.h +++ b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_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 @@ -64,6 +65,18 @@ class PolicyTagManagerSerializationConnectionImpl google::cloud::datacatalog::v1::ExportTaxonomiesRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_logging_decorator.cc b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_logging_decorator.cc index 29f1ef8fe8d73..12f75384394f4 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_logging_decorator.cc +++ b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_logging_decorator.cc @@ -74,6 +74,52 @@ PolicyTagManagerSerializationLogging::ExportTaxonomies( context, options, request, __func__, tracing_options_); } +StatusOr +PolicyTagManagerSerializationLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +PolicyTagManagerSerializationLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status PolicyTagManagerSerializationLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status PolicyTagManagerSerializationLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace datacatalog_v1_internal } // namespace cloud diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_logging_decorator.h b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_logging_decorator.h index 2d8704101e6fc..d9d69f2b7c06a 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_logging_decorator.h +++ b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_logging_decorator.h @@ -56,6 +56,22 @@ class PolicyTagManagerSerializationLogging google::cloud::datacatalog::v1::ExportTaxonomiesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_metadata_decorator.cc b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_metadata_decorator.cc index e5007bd46e6ad..335f9291d99fb 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_metadata_decorator.cc +++ b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_metadata_decorator.cc @@ -71,6 +71,40 @@ PolicyTagManagerSerializationMetadata::ExportTaxonomies( return child_->ExportTaxonomies(context, options, request); } +StatusOr +PolicyTagManagerSerializationMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +PolicyTagManagerSerializationMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status PolicyTagManagerSerializationMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status PolicyTagManagerSerializationMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + void PolicyTagManagerSerializationMetadata::SetMetadata( grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_metadata_decorator.h b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_metadata_decorator.h index 943f0b38eb2ad..f881dbc55048e 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_metadata_decorator.h +++ b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_metadata_decorator.h @@ -57,6 +57,22 @@ class PolicyTagManagerSerializationMetadata google::cloud::datacatalog::v1::ExportTaxonomiesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_stub.cc b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_stub.cc index 87955f81cc2fb..5753a45fd7c69 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_stub.cc +++ b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_stub.cc @@ -67,6 +67,52 @@ DefaultPolicyTagManagerSerializationStub::ExportTaxonomies( return response; } +StatusOr +DefaultPolicyTagManagerSerializationStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPolicyTagManagerSerializationStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultPolicyTagManagerSerializationStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultPolicyTagManagerSerializationStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace datacatalog_v1_internal } // namespace cloud 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..4c1741e577c40 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 @@ -51,6 +52,22 @@ class PolicyTagManagerSerializationStub { grpc::ClientContext& context, Options const& options, google::cloud::datacatalog::v1::ExportTaxonomiesRequest const& request) = 0; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultPolicyTagManagerSerializationStub @@ -59,8 +76,11 @@ class DefaultPolicyTagManagerSerializationStub explicit DefaultPolicyTagManagerSerializationStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr ReplaceTaxonomy( grpc::ClientContext& context, Options const& options, @@ -79,10 +99,28 @@ class DefaultPolicyTagManagerSerializationStub google::cloud::datacatalog::v1::ExportTaxonomiesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_stub_factory.cc b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_stub_factory.cc index b6d4957909179..149ec45cb211f 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_stub_factory.cc +++ b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_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 @@ CreateDefaultPolicyTagManagerSerializationStub( auto service_grpc_stub = google::cloud::datacatalog::v1::PolicyTagManagerSerialization::NewStub( channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_operations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_tracing_connection.cc b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_tracing_connection.cc index bbeac675543c2..3f073c0164763 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_tracing_connection.cc +++ b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_tracing_connection.cc @@ -18,6 +18,7 @@ #include "google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_tracing_connection.h" #include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" #include #include @@ -64,6 +65,45 @@ PolicyTagManagerSerializationTracingConnection::ExportTaxonomies( return internal::EndSpan(*span, child_->ExportTaxonomies(request)); } +StreamRange +PolicyTagManagerSerializationTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "datacatalog_v1::PolicyTagManagerSerializationConnection::" + "ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +PolicyTagManagerSerializationTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "datacatalog_v1::PolicyTagManagerSerializationConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status PolicyTagManagerSerializationTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "datacatalog_v1::PolicyTagManagerSerializationConnection::" + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status PolicyTagManagerSerializationTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "datacatalog_v1::PolicyTagManagerSerializationConnection::" + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_tracing_connection.h b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_tracing_connection.h index c01f1326330e8..b34793c502b8a 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_tracing_connection.h +++ b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_tracing_connection.h @@ -55,6 +55,18 @@ class PolicyTagManagerSerializationTracingConnection google::cloud::datacatalog::v1::ExportTaxonomiesRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_tracing_stub.cc b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_tracing_stub.cc index b0477d2a0fd87..5122c53afee9a 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_tracing_stub.cc +++ b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_tracing_stub.cc @@ -72,6 +72,56 @@ PolicyTagManagerSerializationTracingStub::ExportTaxonomies( child_->ExportTaxonomies(context, options, request)); } +StatusOr +PolicyTagManagerSerializationTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.datacatalog.v1.PolicyTagManagerSerialization", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +PolicyTagManagerSerializationTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.datacatalog.v1.PolicyTagManagerSerialization", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status PolicyTagManagerSerializationTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.datacatalog.v1.PolicyTagManagerSerialization", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status PolicyTagManagerSerializationTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.datacatalog.v1.PolicyTagManagerSerialization", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_tracing_stub.h b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_tracing_stub.h index 69967659e9a46..f8396acc2f6e2 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_tracing_stub.h +++ b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_tracing_stub.h @@ -57,6 +57,22 @@ class PolicyTagManagerSerializationTracingStub google::cloud::datacatalog::v1::ExportTaxonomiesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_stub.cc b/google/cloud/datacatalog/v1/internal/policy_tag_manager_stub.cc index b5e76632508cd..6046bd327802c 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_stub.cc +++ b/google/cloud/datacatalog/v1/internal/policy_tag_manager_stub.cc @@ -182,6 +182,52 @@ DefaultPolicyTagManagerStub::TestIamPermissions( return response; } +StatusOr +DefaultPolicyTagManagerStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPolicyTagManagerStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultPolicyTagManagerStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultPolicyTagManagerStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace datacatalog_v1_internal } // namespace cloud 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..5e07f2791840c 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 @@ -92,6 +93,22 @@ class PolicyTagManagerStub { TestIamPermissions( grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) = 0; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultPolicyTagManagerStub : public PolicyTagManagerStub { @@ -99,8 +116,11 @@ class DefaultPolicyTagManagerStub : public PolicyTagManagerStub { explicit DefaultPolicyTagManagerStub( std::unique_ptr< google::cloud::datacatalog::v1::PolicyTagManager::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr CreateTaxonomy( grpc::ClientContext& context, Options const& options, @@ -164,10 +184,28 @@ class DefaultPolicyTagManagerStub : public PolicyTagManagerStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr< google::cloud::datacatalog::v1::PolicyTagManager::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_stub_factory.cc b/google/cloud/datacatalog/v1/internal/policy_tag_manager_stub_factory.cc index 34fff2b1ae4d9..89bb82319d8b8 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_stub_factory.cc +++ b/google/cloud/datacatalog/v1/internal/policy_tag_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,11 @@ std::shared_ptr CreateDefaultPolicyTagManagerStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::datacatalog::v1::PolicyTagManager::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_operations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_tracing_connection.cc b/google/cloud/datacatalog/v1/internal/policy_tag_manager_tracing_connection.cc index 61917740855a8..d2f79e86df8e9 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_tracing_connection.cc +++ b/google/cloud/datacatalog/v1/internal/policy_tag_manager_tracing_connection.cc @@ -153,6 +153,42 @@ PolicyTagManagerTracingConnection::TestIamPermissions( return internal::EndSpan(*span, child_->TestIamPermissions(request)); } +StreamRange +PolicyTagManagerTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "datacatalog_v1::PolicyTagManagerConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +PolicyTagManagerTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "datacatalog_v1::PolicyTagManagerConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status PolicyTagManagerTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "datacatalog_v1::PolicyTagManagerConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status PolicyTagManagerTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "datacatalog_v1::PolicyTagManagerConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_tracing_connection.h b/google/cloud/datacatalog/v1/internal/policy_tag_manager_tracing_connection.h index b9e53a6a350b0..65551da106834 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_tracing_connection.h +++ b/google/cloud/datacatalog/v1/internal/policy_tag_manager_tracing_connection.h @@ -87,6 +87,18 @@ class PolicyTagManagerTracingConnection StatusOr TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_tracing_stub.cc b/google/cloud/datacatalog/v1/internal/policy_tag_manager_tracing_stub.cc index 7f93360eefaa5..b1550cdf7374a 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_tracing_stub.cc +++ b/google/cloud/datacatalog/v1/internal/policy_tag_manager_tracing_stub.cc @@ -184,6 +184,52 @@ PolicyTagManagerTracingStub::TestIamPermissions( context, *span, child_->TestIamPermissions(context, options, request)); } +StatusOr +PolicyTagManagerTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.datacatalog.v1.PolicyTagManager", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +PolicyTagManagerTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.datacatalog.v1.PolicyTagManager", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status PolicyTagManagerTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.datacatalog.v1.PolicyTagManager", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status PolicyTagManagerTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.datacatalog.v1.PolicyTagManager", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakePolicyTagManagerTracingStub( diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_tracing_stub.h b/google/cloud/datacatalog/v1/internal/policy_tag_manager_tracing_stub.h index 7b88108c9a770..78c3c9977137e 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_tracing_stub.h +++ b/google/cloud/datacatalog/v1/internal/policy_tag_manager_tracing_stub.h @@ -101,6 +101,22 @@ class PolicyTagManagerTracingStub : public PolicyTagManagerStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/datacatalog/v1/mocks/mock_data_catalog_connection.h b/google/cloud/datacatalog/v1/mocks/mock_data_catalog_connection.h index 5907ce4bb1252..4e524a8b14449 100644 --- a/google/cloud/datacatalog/v1/mocks/mock_data_catalog_connection.h +++ b/google/cloud/datacatalog/v1/mocks/mock_data_catalog_connection.h @@ -289,6 +289,21 @@ class MockDataCatalogConnection : public datacatalog_v1::DataCatalogConnection { future>, ImportEntries, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/datacatalog/v1/mocks/mock_policy_tag_manager_connection.h b/google/cloud/datacatalog/v1/mocks/mock_policy_tag_manager_connection.h index a2611f3424ce4..a6683ea33e9c2 100644 --- a/google/cloud/datacatalog/v1/mocks/mock_policy_tag_manager_connection.h +++ b/google/cloud/datacatalog/v1/mocks/mock_policy_tag_manager_connection.h @@ -109,6 +109,21 @@ class MockPolicyTagManagerConnection TestIamPermissions, (google::iam::v1::TestIamPermissionsRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/datacatalog/v1/mocks/mock_policy_tag_manager_serialization_connection.h b/google/cloud/datacatalog/v1/mocks/mock_policy_tag_manager_serialization_connection.h index e9cca25cb1174..5c2af247b680f 100644 --- a/google/cloud/datacatalog/v1/mocks/mock_policy_tag_manager_serialization_connection.h +++ b/google/cloud/datacatalog/v1/mocks/mock_policy_tag_manager_serialization_connection.h @@ -63,6 +63,21 @@ class MockPolicyTagManagerSerializationConnection ExportTaxonomies, (google::cloud::datacatalog::v1::ExportTaxonomiesRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/datacatalog/v1/policy_tag_manager_client.cc b/google/cloud/datacatalog/v1/policy_tag_manager_client.cc index 595257c7343f2..c450a98278282 100644 --- a/google/cloud/datacatalog/v1/policy_tag_manager_client.cc +++ b/google/cloud/datacatalog/v1/policy_tag_manager_client.cc @@ -219,6 +219,66 @@ PolicyTagManagerClient::TestIamPermissions( return connection_->TestIamPermissions(request); } +StreamRange +PolicyTagManagerClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +PolicyTagManagerClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr PolicyTagManagerClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr PolicyTagManagerClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status PolicyTagManagerClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status PolicyTagManagerClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status PolicyTagManagerClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status PolicyTagManagerClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace datacatalog_v1 } // namespace cloud diff --git a/google/cloud/datacatalog/v1/policy_tag_manager_client.h b/google/cloud/datacatalog/v1/policy_tag_manager_client.h index 9b689b390290d..4f526819c5594 100644 --- a/google/cloud/datacatalog/v1/policy_tag_manager_client.h +++ b/google/cloud/datacatalog/v1/policy_tag_manager_client.h @@ -803,6 +803,286 @@ class PolicyTagManagerClient { google::iam::v1::TestIamPermissionsRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/datacatalog/v1/policy_tag_manager_connection.cc b/google/cloud/datacatalog/v1/policy_tag_manager_connection.cc index 487ba99d7f54b..90f5094910400 100644 --- a/google/cloud/datacatalog/v1/policy_tag_manager_connection.cc +++ b/google/cloud/datacatalog/v1/policy_tag_manager_connection.cc @@ -116,6 +116,30 @@ PolicyTagManagerConnection::TestIamPermissions( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +PolicyTagManagerConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +PolicyTagManagerConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status PolicyTagManagerConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status PolicyTagManagerConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakePolicyTagManagerConnection( Options options) { internal::CheckExpectedOptions TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/datacatalog/v1/policy_tag_manager_connection_idempotency_policy.cc b/google/cloud/datacatalog/v1/policy_tag_manager_connection_idempotency_policy.cc index 13c01485aff4c..fb91d9cdd61f3 100644 --- a/google/cloud/datacatalog/v1/policy_tag_manager_connection_idempotency_policy.cc +++ b/google/cloud/datacatalog/v1/policy_tag_manager_connection_idempotency_policy.cc @@ -100,6 +100,26 @@ Idempotency PolicyTagManagerConnectionIdempotencyPolicy::TestIamPermissions( return Idempotency::kIdempotent; } +Idempotency PolicyTagManagerConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency PolicyTagManagerConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency PolicyTagManagerConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency PolicyTagManagerConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultPolicyTagManagerConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/datacatalog/v1/policy_tag_manager_connection_idempotency_policy.h b/google/cloud/datacatalog/v1/policy_tag_manager_connection_idempotency_policy.h index d96efa9a98d39..fed5d1f9f4ea3 100644 --- a/google/cloud/datacatalog/v1/policy_tag_manager_connection_idempotency_policy.h +++ b/google/cloud/datacatalog/v1/policy_tag_manager_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,18 @@ class PolicyTagManagerConnectionIdempotencyPolicy { virtual google::cloud::Idempotency TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/datacatalog/v1/policy_tag_manager_serialization_client.cc b/google/cloud/datacatalog/v1/policy_tag_manager_serialization_client.cc index ea85ec464ab33..f121c15aed48a 100644 --- a/google/cloud/datacatalog/v1/policy_tag_manager_serialization_client.cc +++ b/google/cloud/datacatalog/v1/policy_tag_manager_serialization_client.cc @@ -58,6 +58,68 @@ PolicyTagManagerSerializationClient::ExportTaxonomies( return connection_->ExportTaxonomies(request); } +StreamRange +PolicyTagManagerSerializationClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +PolicyTagManagerSerializationClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +PolicyTagManagerSerializationClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +PolicyTagManagerSerializationClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status PolicyTagManagerSerializationClient::DeleteOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status PolicyTagManagerSerializationClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status PolicyTagManagerSerializationClient::CancelOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status PolicyTagManagerSerializationClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace datacatalog_v1 } // namespace cloud diff --git a/google/cloud/datacatalog/v1/policy_tag_manager_serialization_client.h b/google/cloud/datacatalog/v1/policy_tag_manager_serialization_client.h index 914d1ae6ecb18..941320f2454fc 100644 --- a/google/cloud/datacatalog/v1/policy_tag_manager_serialization_client.h +++ b/google/cloud/datacatalog/v1/policy_tag_manager_serialization_client.h @@ -212,6 +212,286 @@ class PolicyTagManagerSerializationClient { google::cloud::datacatalog::v1::ExportTaxonomiesRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/datacatalog/v1/policy_tag_manager_serialization_connection.cc b/google/cloud/datacatalog/v1/policy_tag_manager_serialization_connection.cc index 8067f347ed14c..44979ec4139e6 100644 --- a/google/cloud/datacatalog/v1/policy_tag_manager_serialization_connection.cc +++ b/google/cloud/datacatalog/v1/policy_tag_manager_serialization_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 @@ -56,6 +57,30 @@ PolicyTagManagerSerializationConnection::ExportTaxonomies( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +PolicyTagManagerSerializationConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +PolicyTagManagerSerializationConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status PolicyTagManagerSerializationConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status PolicyTagManagerSerializationConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakePolicyTagManagerSerializationConnection(Options options) { internal::CheckExpectedOptions #include @@ -209,6 +210,18 @@ class PolicyTagManagerSerializationConnection { virtual StatusOr ExportTaxonomies( google::cloud::datacatalog::v1::ExportTaxonomiesRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/datacatalog/v1/policy_tag_manager_serialization_connection_idempotency_policy.cc b/google/cloud/datacatalog/v1/policy_tag_manager_serialization_connection_idempotency_policy.cc index e143d4154b7d4..09611a673576a 100644 --- a/google/cloud/datacatalog/v1/policy_tag_manager_serialization_connection_idempotency_policy.cc +++ b/google/cloud/datacatalog/v1/policy_tag_manager_serialization_connection_idempotency_policy.cc @@ -53,6 +53,30 @@ PolicyTagManagerSerializationConnectionIdempotencyPolicy::ExportTaxonomies( return Idempotency::kIdempotent; } +Idempotency +PolicyTagManagerSerializationConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency +PolicyTagManagerSerializationConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +PolicyTagManagerSerializationConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency +PolicyTagManagerSerializationConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultPolicyTagManagerSerializationConnectionIdempotencyPolicy() { return std::make_unique< diff --git a/google/cloud/datacatalog/v1/policy_tag_manager_serialization_connection_idempotency_policy.h b/google/cloud/datacatalog/v1/policy_tag_manager_serialization_connection_idempotency_policy.h index 20479c91618fd..d1877fb198986 100644 --- a/google/cloud/datacatalog/v1/policy_tag_manager_serialization_connection_idempotency_policy.h +++ b/google/cloud/datacatalog/v1/policy_tag_manager_serialization_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -46,6 +47,18 @@ class PolicyTagManagerSerializationConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ExportTaxonomies( google::cloud::datacatalog::v1::ExportTaxonomiesRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr 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..f193bf6b8bf81 100644 --- a/google/cloud/dataplex/v1/catalog_client.cc +++ b/google/cloud/dataplex/v1/catalog_client.cc @@ -621,6 +621,97 @@ 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); +} + +StreamRange +CatalogServiceClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +CatalogServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr CatalogServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr CatalogServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status CatalogServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status CatalogServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status CatalogServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status CatalogServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..0b9eb469b92f3 100644 --- a/google/cloud/dataplex/v1/catalog_client.h +++ b/google/cloud/dataplex/v1/catalog_client.h @@ -1978,6 +1978,458 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..d3ac7aaf46105 100644 --- a/google/cloud/dataplex/v1/catalog_connection.cc +++ b/google/cloud/dataplex/v1/catalog_connection.cc @@ -332,6 +332,59 @@ 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"); +} + +StreamRange +CatalogServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr CatalogServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status CatalogServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status CatalogServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeCatalogServiceConnection( Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..52c355cbe3f53 100644 --- a/google/cloud/dataplex/v1/catalog_connection_idempotency_policy.cc +++ b/google/cloud/dataplex/v1/catalog_connection_idempotency_policy.cc @@ -144,6 +144,52 @@ 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; +} + +Idempotency CatalogServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency CatalogServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency CatalogServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency CatalogServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..537dde8df596e 100644 --- a/google/cloud/dataplex/v1/catalog_connection_idempotency_policy.h +++ b/google/cloud/dataplex/v1/catalog_connection_idempotency_policy.h @@ -22,6 +22,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -102,6 +105,33 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..eeab3a30a3e1b 100644 --- a/google/cloud/dataplex/v1/content_client.cc +++ b/google/cloud/dataplex/v1/content_client.cc @@ -142,6 +142,78 @@ 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); +} + +StreamRange +ContentServiceClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +ContentServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr ContentServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr ContentServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status ContentServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status ContentServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status ContentServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status ContentServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..cd65139e29afa 100644 --- a/google/cloud/dataplex/v1/content_client.h +++ b/google/cloud/dataplex/v1/content_client.h @@ -526,6 +526,356 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..5d1e044e8f973 100644 --- a/google/cloud/dataplex/v1/content_connection.cc +++ b/google/cloud/dataplex/v1/content_connection.cc @@ -85,6 +85,43 @@ 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"); +} + +StreamRange +ContentServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr ContentServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ContentServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ContentServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeContentServiceConnection( Options options) { internal::CheckExpectedOptions ListContent( google::cloud::dataplex::v1::ListContentRequest request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..656c65cb95ecf 100644 --- a/google/cloud/dataplex/v1/content_connection_idempotency_policy.cc +++ b/google/cloud/dataplex/v1/content_connection_idempotency_policy.cc @@ -75,6 +75,36 @@ 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; +} + +Idempotency ContentServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ContentServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ContentServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency ContentServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..1525c33859c9c 100644 --- a/google/cloud/dataplex/v1/content_connection_idempotency_policy.h +++ b/google/cloud/dataplex/v1/content_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,24 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..ffe37e734cc59 100644 --- a/google/cloud/dataplex/v1/data_scan_client.cc +++ b/google/cloud/dataplex/v1/data_scan_client.cc @@ -260,6 +260,97 @@ 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); +} + +StreamRange +DataScanServiceClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +DataScanServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr DataScanServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr DataScanServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status DataScanServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status DataScanServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status DataScanServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status DataScanServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..ffc5f1a4cff32 100644 --- a/google/cloud/dataplex/v1/data_scan_client.h +++ b/google/cloud/dataplex/v1/data_scan_client.h @@ -853,6 +853,458 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..c5224e50b6e60 100644 --- a/google/cloud/dataplex/v1/data_scan_connection.cc +++ b/google/cloud/dataplex/v1/data_scan_connection.cc @@ -147,6 +147,60 @@ 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"); +} + +StreamRange +DataScanServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +DataScanServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DataScanServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DataScanServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDataScanServiceConnection( Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..c2d434cc41e6f 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,52 @@ 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; +} + +Idempotency DataScanServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DataScanServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DataScanServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency DataScanServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..ed6353877727b 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,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -64,6 +67,33 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..4b22239419292 100644 --- a/google/cloud/dataplex/v1/data_taxonomy_client.cc +++ b/google/cloud/dataplex/v1/data_taxonomy_client.cc @@ -563,6 +563,100 @@ 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); +} + +StreamRange +DataTaxonomyServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +DataTaxonomyServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +DataTaxonomyServiceClient::GetOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +DataTaxonomyServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status DataTaxonomyServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status DataTaxonomyServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status DataTaxonomyServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status DataTaxonomyServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..956e3a2705bbe 100644 --- a/google/cloud/dataplex/v1/data_taxonomy_client.h +++ b/google/cloud/dataplex/v1/data_taxonomy_client.h @@ -1591,6 +1591,458 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..e6a9c5af45935 100644 --- a/google/cloud/dataplex/v1/data_taxonomy_connection.cc +++ b/google/cloud/dataplex/v1/data_taxonomy_connection.cc @@ -293,6 +293,60 @@ 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"); +} + +StreamRange +DataTaxonomyServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +DataTaxonomyServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DataTaxonomyServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DataTaxonomyServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDataTaxonomyServiceConnection(Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..81f70186ad284 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,52 @@ 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; +} + +Idempotency DataTaxonomyServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DataTaxonomyServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DataTaxonomyServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency DataTaxonomyServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..eb80386005071 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,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -85,6 +88,33 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..63113e9ffe92e 100644 --- a/google/cloud/dataplex/v1/dataplex_client.cc +++ b/google/cloud/dataplex/v1/dataplex_client.cc @@ -945,6 +945,97 @@ 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); +} + +StreamRange +DataplexServiceClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +DataplexServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr DataplexServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr DataplexServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status DataplexServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status DataplexServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status DataplexServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status DataplexServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..5062cd55398d1 100644 --- a/google/cloud/dataplex/v1/dataplex_client.h +++ b/google/cloud/dataplex/v1/dataplex_client.h @@ -3057,6 +3057,458 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..ea3d8b605ab8e 100644 --- a/google/cloud/dataplex/v1/dataplex_connection.cc +++ b/google/cloud/dataplex/v1/dataplex_connection.cc @@ -482,6 +482,60 @@ 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"); +} + +StreamRange +DataplexServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +DataplexServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DataplexServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DataplexServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDataplexServiceConnection( Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..ca558dc1fa581 100644 --- a/google/cloud/dataplex/v1/dataplex_connection_idempotency_policy.cc +++ b/google/cloud/dataplex/v1/dataplex_connection_idempotency_policy.cc @@ -199,6 +199,52 @@ 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; +} + +Idempotency DataplexServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DataplexServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DataplexServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency DataplexServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..509c0e2ff4ece 100644 --- a/google/cloud/dataplex/v1/dataplex_connection_idempotency_policy.h +++ b/google/cloud/dataplex/v1/dataplex_connection_idempotency_policy.h @@ -22,6 +22,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -135,6 +138,33 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..8da0017aaf190 100644 --- a/google/cloud/dataplex/v1/internal/catalog_auth_decorator.cc +++ b/google/cloud/dataplex/v1/internal/catalog_auth_decorator.cc @@ -395,6 +395,81 @@ 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); +} + +StatusOr +CatalogServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr CatalogServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status CatalogServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status CatalogServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..567ea5b65e405 100644 --- a/google/cloud/dataplex/v1/internal/catalog_auth_decorator.h +++ b/google/cloud/dataplex/v1/internal/catalog_auth_decorator.h @@ -205,6 +205,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..9b24a80724dfa 100644 --- a/google/cloud/dataplex/v1/internal/catalog_connection_impl.cc +++ b/google/cloud/dataplex/v1/internal/catalog_connection_impl.cc @@ -1168,6 +1168,167 @@ 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__); +} + +StreamRange +CatalogServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +CatalogServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status CatalogServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status CatalogServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..36e4e748df047 100644 --- a/google/cloud/dataplex/v1/internal/catalog_connection_impl.h +++ b/google/cloud/dataplex/v1/internal/catalog_connection_impl.h @@ -201,6 +201,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..e5eaeda9a9762 100644 --- a/google/cloud/dataplex/v1/internal/catalog_logging_decorator.cc +++ b/google/cloud/dataplex/v1/internal/catalog_logging_decorator.cc @@ -474,6 +474,108 @@ 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_); +} + +StatusOr +CatalogServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr CatalogServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status CatalogServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status CatalogServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..fcdd1b08ea1b4 100644 --- a/google/cloud/dataplex/v1/internal/catalog_logging_decorator.h +++ b/google/cloud/dataplex/v1/internal/catalog_logging_decorator.h @@ -205,6 +205,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..96ee72f847d9e 100644 --- a/google/cloud/dataplex/v1/internal/catalog_metadata_decorator.cc +++ b/google/cloud/dataplex/v1/internal/catalog_metadata_decorator.cc @@ -356,6 +356,84 @@ 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); +} + +StatusOr +CatalogServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr CatalogServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status CatalogServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status CatalogServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..28a4108110202 100644 --- a/google/cloud/dataplex/v1/internal/catalog_metadata_decorator.h +++ b/google/cloud/dataplex/v1/internal/catalog_metadata_decorator.h @@ -205,6 +205,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..6ce655bca131e 100644 --- a/google/cloud/dataplex/v1/internal/catalog_stub.cc +++ b/google/cloud/dataplex/v1/internal/catalog_stub.cc @@ -463,6 +463,111 @@ 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; +} + +StatusOr +DefaultCatalogServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultCatalogServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultCatalogServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultCatalogServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..241bd8afd4069 100644 --- a/google/cloud/dataplex/v1/internal/catalog_stub.h +++ b/google/cloud/dataplex/v1/internal/catalog_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -191,6 +193,44 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -210,9 +250,18 @@ class DefaultCatalogServiceStub : public CatalogServiceStub { std::unique_ptr< google::cloud::dataplex::v1::CatalogService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +429,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -395,6 +480,11 @@ class DefaultCatalogServiceStub : public CatalogServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..22ed07b5e9f32 100644 --- a/google/cloud/dataplex/v1/internal/catalog_stub_factory.cc +++ b/google/cloud/dataplex/v1/internal/catalog_stub_factory.cc @@ -29,6 +29,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultCatalogServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dataplex::v1::CatalogService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..12ee12084f624 100644 --- a/google/cloud/dataplex/v1/internal/catalog_tracing_connection.cc +++ b/google/cloud/dataplex/v1/internal/catalog_tracing_connection.cc @@ -428,6 +428,87 @@ 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)); +} + +StreamRange +CatalogServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dataplex_v1::CatalogServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +CatalogServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("dataplex_v1::CatalogServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status CatalogServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::CatalogServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status CatalogServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::CatalogServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..281a99d2e86b6 100644 --- a/google/cloud/dataplex/v1/internal/catalog_tracing_connection.h +++ b/google/cloud/dataplex/v1/internal/catalog_tracing_connection.h @@ -189,6 +189,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..4a6aa802d9367 100644 --- a/google/cloud/dataplex/v1/internal/catalog_tracing_stub.cc +++ b/google/cloud/dataplex/v1/internal/catalog_tracing_stub.cc @@ -431,6 +431,110 @@ 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)); +} + +StatusOr +CatalogServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.CatalogService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +CatalogServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.CatalogService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status CatalogServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.CatalogService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status CatalogServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.CatalogService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..348560406c545 100644 --- a/google/cloud/dataplex/v1/internal/catalog_tracing_stub.h +++ b/google/cloud/dataplex/v1/internal/catalog_tracing_stub.h @@ -204,6 +204,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..623c29b692aa6 100644 --- a/google/cloud/dataplex/v1/internal/content_auth_decorator.cc +++ b/google/cloud/dataplex/v1/internal/content_auth_decorator.cc @@ -99,6 +99,56 @@ 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); +} + +StatusOr +ContentServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr ContentServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status ContentServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status ContentServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..1f5316080cc0f 100644 --- a/google/cloud/dataplex/v1/internal/content_auth_decorator.h +++ b/google/cloud/dataplex/v1/internal/content_auth_decorator.h @@ -72,6 +72,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..1240a8888a465 100644 --- a/google/cloud/dataplex/v1/internal/content_connection_impl.cc +++ b/google/cloud/dataplex/v1/internal/content_connection_impl.cc @@ -188,6 +188,127 @@ 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__); +} + +StreamRange +ContentServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ContentServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ContentServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ContentServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..095a63f8328a8 100644 --- a/google/cloud/dataplex/v1/internal/content_connection_impl.h +++ b/google/cloud/dataplex/v1/internal/content_connection_impl.h @@ -75,6 +75,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..c6cce6e433c35 100644 --- a/google/cloud/dataplex/v1/internal/content_logging_decorator.cc +++ b/google/cloud/dataplex/v1/internal/content_logging_decorator.cc @@ -128,6 +128,74 @@ 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_); +} + +StatusOr +ContentServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ContentServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ContentServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ContentServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..51677930a4578 100644 --- a/google/cloud/dataplex/v1/internal/content_logging_decorator.h +++ b/google/cloud/dataplex/v1/internal/content_logging_decorator.h @@ -72,6 +72,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..1820620905183 100644 --- a/google/cloud/dataplex/v1/internal/content_metadata_decorator.cc +++ b/google/cloud/dataplex/v1/internal/content_metadata_decorator.cc @@ -117,6 +117,56 @@ 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); +} + +StatusOr +ContentServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr ContentServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status ContentServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status ContentServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..293f3d7d47527 100644 --- a/google/cloud/dataplex/v1/internal/content_metadata_decorator.h +++ b/google/cloud/dataplex/v1/internal/content_metadata_decorator.h @@ -72,6 +72,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..f1d82d59dfa0f 100644 --- a/google/cloud/dataplex/v1/internal/content_stub.cc +++ b/google/cloud/dataplex/v1/internal/content_stub.cc @@ -123,6 +123,76 @@ 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; +} + +StatusOr +DefaultContentServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultContentServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultContentServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultContentServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..ebb66fef88d2b 100644 --- a/google/cloud/dataplex/v1/internal/content_stub.h +++ b/google/cloud/dataplex/v1/internal/content_stub.h @@ -23,6 +23,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include @@ -68,6 +70,31 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultContentServiceStub : public ContentServiceStub { @@ -75,8 +102,14 @@ 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 + operations_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr CreateContent( grpc::ClientContext& context, Options const& options, @@ -112,9 +145,37 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..93a6c1992b2ba 100644 --- a/google/cloud/dataplex/v1/internal/content_stub_factory.cc +++ b/google/cloud/dataplex/v1/internal/content_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,14 @@ std::shared_ptr CreateDefaultContentServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dataplex::v1::ContentService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..d29319e81dde2 100644 --- a/google/cloud/dataplex/v1/internal/content_tracing_connection.cc +++ b/google/cloud/dataplex/v1/internal/content_tracing_connection.cc @@ -104,6 +104,62 @@ 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)); +} + +StreamRange +ContentServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dataplex_v1::ContentServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ContentServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("dataplex_v1::ContentServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status ContentServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::ContentServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status ContentServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::ContentServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..7dca58d364786 100644 --- a/google/cloud/dataplex/v1/internal/content_tracing_connection.h +++ b/google/cloud/dataplex/v1/internal/content_tracing_connection.h @@ -66,6 +66,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..c4a2382f6d30c 100644 --- a/google/cloud/dataplex/v1/internal/content_tracing_stub.cc +++ b/google/cloud/dataplex/v1/internal/content_tracing_stub.cc @@ -125,6 +125,76 @@ 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)); +} + +StatusOr +ContentServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.ContentService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +ContentServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.ContentService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status ContentServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.ContentService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status ContentServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.ContentService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..11217eabb333c 100644 --- a/google/cloud/dataplex/v1/internal/content_tracing_stub.h +++ b/google/cloud/dataplex/v1/internal/content_tracing_stub.h @@ -72,6 +72,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..3caffb9e2c1f8 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,81 @@ 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); +} + +StatusOr +DataScanServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr DataScanServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status DataScanServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status DataScanServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..b57041e746802 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..82456360c9a61 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,167 @@ 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__); +} + +StreamRange +DataScanServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DataScanServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DataScanServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DataScanServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..cd3c80919b6b3 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..b07ac282941ed 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,108 @@ 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_); +} + +StatusOr +DataScanServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DataScanServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DataScanServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DataScanServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..f444b1150c98c 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..a5a24befd80cb 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,85 @@ 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); +} + +StatusOr +DataScanServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr DataScanServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status DataScanServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status DataScanServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..826b700b75135 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..1e58830ebbe31 100644 --- a/google/cloud/dataplex/v1/internal/data_scan_stub.cc +++ b/google/cloud/dataplex/v1/internal/data_scan_stub.cc @@ -195,6 +195,111 @@ 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; +} + +StatusOr +DefaultDataScanServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataScanServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultDataScanServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultDataScanServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..15959f65553b3 100644 --- a/google/cloud/dataplex/v1/internal/data_scan_stub.h +++ b/google/cloud/dataplex/v1/internal/data_scan_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -98,6 +100,44 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -117,9 +157,18 @@ class DefaultDataScanServiceStub : public DataScanServiceStub { std::unique_ptr< google::cloud::dataplex::v1::DataScanService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +235,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -201,6 +286,11 @@ class DefaultDataScanServiceStub : public DataScanServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..a7d49521a5550 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,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultDataScanServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dataplex::v1::DataScanService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..8c95fbd7ea0ee 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,89 @@ 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)); +} + +StreamRange +DataScanServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dataplex_v1::DataScanServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DataScanServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::DataScanServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status DataScanServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::DataScanServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status DataScanServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::DataScanServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..5eb629adc7121 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..be3c6d908f33c 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,110 @@ 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)); +} + +StatusOr +DataScanServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.DataScanService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +DataScanServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.DataScanService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status DataScanServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.DataScanService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status DataScanServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.DataScanService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..18e5f31aa8ae3 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..177781b94cc0b 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,82 @@ 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); +} + +StatusOr +DataTaxonomyServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr DataTaxonomyServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status DataTaxonomyServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status DataTaxonomyServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..48ca9d750e177 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..d2dc010953634 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,169 @@ 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__); +} + +StreamRange +DataTaxonomyServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DataTaxonomyServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DataTaxonomyServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DataTaxonomyServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..61eb83f336960 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..63da576503f42 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,110 @@ 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_); +} + +StatusOr +DataTaxonomyServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataTaxonomyServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DataTaxonomyServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DataTaxonomyServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..8b02a4936371b 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..cd384264fb317 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,86 @@ 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); +} + +StatusOr +DataTaxonomyServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +DataTaxonomyServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status DataTaxonomyServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status DataTaxonomyServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..d224f2898bd0f 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..aaa374f749bf7 100644 --- a/google/cloud/dataplex/v1/internal/data_taxonomy_stub.cc +++ b/google/cloud/dataplex/v1/internal/data_taxonomy_stub.cc @@ -401,6 +401,111 @@ 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; +} + +StatusOr +DefaultDataTaxonomyServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataTaxonomyServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultDataTaxonomyServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultDataTaxonomyServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..bd78b055e2121 100644 --- a/google/cloud/dataplex/v1/internal/data_taxonomy_stub.h +++ b/google/cloud/dataplex/v1/internal/data_taxonomy_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -188,6 +190,44 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -207,9 +247,18 @@ class DefaultDataTaxonomyServiceStub : public DataTaxonomyServiceStub { std::unique_ptr< google::cloud::dataplex::v1::DataTaxonomyService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +405,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -372,6 +457,11 @@ class DefaultDataTaxonomyServiceStub : public DataTaxonomyServiceStub { std::unique_ptr< google::cloud::dataplex::v1::DataTaxonomyService::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..8c98777a1ec2a 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,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultDataTaxonomyServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dataplex::v1::DataTaxonomyService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..0006a14ec6c35 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,89 @@ 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)); +} + +StreamRange +DataTaxonomyServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dataplex_v1::DataTaxonomyServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DataTaxonomyServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::DataTaxonomyServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status DataTaxonomyServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::DataTaxonomyServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status DataTaxonomyServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::DataTaxonomyServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..a7c456744ec4b 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..689db83e3d457 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,110 @@ 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)); +} + +StatusOr +DataTaxonomyServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataplex.v1.DataTaxonomyService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +DataTaxonomyServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataplex.v1.DataTaxonomyService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status DataTaxonomyServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataplex.v1.DataTaxonomyService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status DataTaxonomyServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataplex.v1.DataTaxonomyService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..ff196826e1557 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..a92508ba657d6 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_auth_decorator.cc +++ b/google/cloud/dataplex/v1/internal/dataplex_auth_decorator.cc @@ -607,6 +607,81 @@ 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); +} + +StatusOr +DataplexServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr DataplexServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status DataplexServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status DataplexServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..806044ec00d1e 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_auth_decorator.h +++ b/google/cloud/dataplex/v1/internal/dataplex_auth_decorator.h @@ -272,6 +272,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..ab84aa1bd50ed 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_connection_impl.cc +++ b/google/cloud/dataplex/v1/internal/dataplex_connection_impl.cc @@ -1868,6 +1868,167 @@ 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__); +} + +StreamRange +DataplexServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DataplexServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DataplexServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DataplexServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..0103c766fc611 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_connection_impl.h +++ b/google/cloud/dataplex/v1/internal/dataplex_connection_impl.h @@ -263,6 +263,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..deee104d94539 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_logging_decorator.cc +++ b/google/cloud/dataplex/v1/internal/dataplex_logging_decorator.cc @@ -694,6 +694,108 @@ 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_); +} + +StatusOr +DataplexServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DataplexServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DataplexServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DataplexServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..508c3f78e371b 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_logging_decorator.h +++ b/google/cloud/dataplex/v1/internal/dataplex_logging_decorator.h @@ -272,6 +272,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..2745afd776409 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_metadata_decorator.cc +++ b/google/cloud/dataplex/v1/internal/dataplex_metadata_decorator.cc @@ -513,6 +513,85 @@ 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); +} + +StatusOr +DataplexServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr DataplexServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status DataplexServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status DataplexServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..1aed7959892a7 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_metadata_decorator.h +++ b/google/cloud/dataplex/v1/internal/dataplex_metadata_decorator.h @@ -273,6 +273,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..f459e7d1d7ebf 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_stub.cc +++ b/google/cloud/dataplex/v1/internal/dataplex_stub.cc @@ -686,6 +686,111 @@ 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; +} + +StatusOr +DefaultDataplexServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataplexServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultDataplexServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultDataplexServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..9508fd9105d3e 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_stub.h +++ b/google/cloud/dataplex/v1/internal/dataplex_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -268,6 +270,44 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -287,9 +327,18 @@ class DefaultDataplexServiceStub : public DataplexServiceStub { std::unique_ptr< google::cloud::dataplex::v1::DataplexService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +573,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -539,6 +624,11 @@ class DefaultDataplexServiceStub : public DataplexServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..a0837573d2940 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_stub_factory.cc +++ b/google/cloud/dataplex/v1/internal/dataplex_stub_factory.cc @@ -29,6 +29,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultDataplexServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dataplex::v1::DataplexService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..32f5b04babdee 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_tracing_connection.cc +++ b/google/cloud/dataplex/v1/internal/dataplex_tracing_connection.cc @@ -631,6 +631,89 @@ 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)); +} + +StreamRange +DataplexServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dataplex_v1::DataplexServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DataplexServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::DataplexServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status DataplexServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::DataplexServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status DataplexServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::DataplexServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..abe90dd27735b 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_tracing_connection.h +++ b/google/cloud/dataplex/v1/internal/dataplex_tracing_connection.h @@ -251,6 +251,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..6492eb83c7fc0 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_tracing_stub.cc +++ b/google/cloud/dataplex/v1/internal/dataplex_tracing_stub.cc @@ -627,6 +627,110 @@ 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)); +} + +StatusOr +DataplexServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.DataplexService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +DataplexServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.DataplexService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status DataplexServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.DataplexService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status DataplexServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.DataplexService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..c12e67cca3a91 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_tracing_stub.h +++ b/google/cloud/dataplex/v1/internal/dataplex_tracing_stub.h @@ -272,6 +272,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..7e0a06b072dae 100644 --- a/google/cloud/dataplex/v1/internal/metadata_auth_decorator.cc +++ b/google/cloud/dataplex/v1/internal/metadata_auth_decorator.cc @@ -107,6 +107,81 @@ 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); +} + +StatusOr +MetadataServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr MetadataServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status MetadataServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status MetadataServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..c2cf972495f6c 100644 --- a/google/cloud/dataplex/v1/internal/metadata_auth_decorator.h +++ b/google/cloud/dataplex/v1/internal/metadata_auth_decorator.h @@ -77,6 +77,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..b31c904fa1919 100644 --- a/google/cloud/dataplex/v1/internal/metadata_connection_impl.cc +++ b/google/cloud/dataplex/v1/internal/metadata_connection_impl.cc @@ -226,6 +226,167 @@ 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__); +} + +StreamRange +MetadataServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +MetadataServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status MetadataServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status MetadataServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..65a1c6f2ff1e1 100644 --- a/google/cloud/dataplex/v1/internal/metadata_connection_impl.h +++ b/google/cloud/dataplex/v1/internal/metadata_connection_impl.h @@ -78,6 +78,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..15858bd0d8234 100644 --- a/google/cloud/dataplex/v1/internal/metadata_logging_decorator.cc +++ b/google/cloud/dataplex/v1/internal/metadata_logging_decorator.cc @@ -143,6 +143,108 @@ 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_); +} + +StatusOr +MetadataServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr MetadataServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status MetadataServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status MetadataServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..786be757ab6bf 100644 --- a/google/cloud/dataplex/v1/internal/metadata_logging_decorator.h +++ b/google/cloud/dataplex/v1/internal/metadata_logging_decorator.h @@ -77,6 +77,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..90b610f69f31b 100644 --- a/google/cloud/dataplex/v1/internal/metadata_metadata_decorator.cc +++ b/google/cloud/dataplex/v1/internal/metadata_metadata_decorator.cc @@ -124,6 +124,85 @@ 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); +} + +StatusOr +MetadataServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr MetadataServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status MetadataServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status MetadataServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..24503f968c317 100644 --- a/google/cloud/dataplex/v1/internal/metadata_metadata_decorator.h +++ b/google/cloud/dataplex/v1/internal/metadata_metadata_decorator.h @@ -78,6 +78,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..42391f6a483e1 100644 --- a/google/cloud/dataplex/v1/internal/metadata_stub.cc +++ b/google/cloud/dataplex/v1/internal/metadata_stub.cc @@ -136,6 +136,111 @@ 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; +} + +StatusOr +DefaultMetadataServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultMetadataServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultMetadataServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultMetadataServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..987c7a1d06834 100644 --- a/google/cloud/dataplex/v1/internal/metadata_stub.h +++ b/google/cloud/dataplex/v1/internal/metadata_stub.h @@ -23,6 +23,9 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include #include #include @@ -72,6 +75,44 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultMetadataServiceStub : public MetadataServiceStub { @@ -79,8 +120,16 @@ 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 + operations_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr CreateEntity( grpc::ClientContext& context, Options const& options, @@ -121,9 +170,50 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..a9d33ef63353e 100644 --- a/google/cloud/dataplex/v1/internal/metadata_stub_factory.cc +++ b/google/cloud/dataplex/v1/internal/metadata_stub_factory.cc @@ -29,6 +29,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultMetadataServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dataplex::v1::MetadataService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..2ed4ace9cd05a 100644 --- a/google/cloud/dataplex/v1/internal/metadata_tracing_connection.cc +++ b/google/cloud/dataplex/v1/internal/metadata_tracing_connection.cc @@ -116,6 +116,89 @@ 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)); +} + +StreamRange +MetadataServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dataplex_v1::MetadataServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +MetadataServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::MetadataServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status MetadataServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::MetadataServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status MetadataServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::MetadataServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..b703eec1cfa2a 100644 --- a/google/cloud/dataplex/v1/internal/metadata_tracing_connection.h +++ b/google/cloud/dataplex/v1/internal/metadata_tracing_connection.h @@ -69,6 +69,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..bff040df06516 100644 --- a/google/cloud/dataplex/v1/internal/metadata_tracing_stub.cc +++ b/google/cloud/dataplex/v1/internal/metadata_tracing_stub.cc @@ -138,6 +138,110 @@ 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)); +} + +StatusOr +MetadataServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.MetadataService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +MetadataServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.MetadataService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status MetadataServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.MetadataService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status MetadataServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.MetadataService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..43bd2d4b51804 100644 --- a/google/cloud/dataplex/v1/internal/metadata_tracing_stub.h +++ b/google/cloud/dataplex/v1/internal/metadata_tracing_stub.h @@ -78,6 +78,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..bab3a16cd83d6 100644 --- a/google/cloud/dataplex/v1/metadata_client.cc +++ b/google/cloud/dataplex/v1/metadata_client.cc @@ -169,6 +169,97 @@ 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); +} + +StreamRange +MetadataServiceClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +MetadataServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr MetadataServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr MetadataServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status MetadataServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status MetadataServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status MetadataServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status MetadataServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..433543a508e81 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,458 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..0afccbde89c4a 100644 --- a/google/cloud/dataplex/v1/metadata_connection.cc +++ b/google/cloud/dataplex/v1/metadata_connection.cc @@ -94,6 +94,60 @@ 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"); +} + +StreamRange +MetadataServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +MetadataServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status MetadataServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status MetadataServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeMetadataServiceConnection( Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..84b902465ca3f 100644 --- a/google/cloud/dataplex/v1/metadata_connection_idempotency_policy.cc +++ b/google/cloud/dataplex/v1/metadata_connection_idempotency_policy.cc @@ -79,6 +79,52 @@ 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; +} + +Idempotency MetadataServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency MetadataServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency MetadataServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency MetadataServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..981d20cc77cbf 100644 --- a/google/cloud/dataplex/v1/metadata_connection_idempotency_policy.h +++ b/google/cloud/dataplex/v1/metadata_connection_idempotency_policy.h @@ -22,6 +22,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -63,6 +66,33 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..6ab132900f783 100644 --- a/google/cloud/dataplex/v1/mocks/mock_catalog_connection.h +++ b/google/cloud/dataplex/v1/mocks/mock_catalog_connection.h @@ -453,6 +453,42 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..998e0d3122b62 100644 --- a/google/cloud/dataplex/v1/mocks/mock_content_connection.h +++ b/google/cloud/dataplex/v1/mocks/mock_content_connection.h @@ -82,6 +82,29 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..28d74f9759993 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,42 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..1cd20d20a02e0 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,42 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..d513d5740ecc9 100644 --- a/google/cloud/dataplex/v1/mocks/mock_dataplex_connection.h +++ b/google/cloud/dataplex/v1/mocks/mock_dataplex_connection.h @@ -668,6 +668,42 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..3f792d39edb83 100644 --- a/google/cloud/dataplex/v1/mocks/mock_metadata_connection.h +++ b/google/cloud/dataplex/v1/mocks/mock_metadata_connection.h @@ -85,6 +85,42 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..1c563980e3257 100644 --- a/google/cloud/dataproc/v1/autoscaling_policy_client.cc +++ b/google/cloud/dataproc/v1/autoscaling_policy_client.cc @@ -120,6 +120,87 @@ 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); +} + +StreamRange +AutoscalingPolicyServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +AutoscalingPolicyServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +AutoscalingPolicyServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +AutoscalingPolicyServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status AutoscalingPolicyServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status AutoscalingPolicyServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status AutoscalingPolicyServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status AutoscalingPolicyServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..db8cebea2a830 100644 --- a/google/cloud/dataproc/v1/autoscaling_policy_client.h +++ b/google/cloud/dataproc/v1/autoscaling_policy_client.h @@ -438,6 +438,388 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..5227740e4f3bd 100644 --- a/google/cloud/dataproc/v1/autoscaling_policy_connection.cc +++ b/google/cloud/dataproc/v1/autoscaling_policy_connection.cc @@ -70,6 +70,48 @@ 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"); +} + +StreamRange +AutoscalingPolicyServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +AutoscalingPolicyServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AutoscalingPolicyServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AutoscalingPolicyServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest 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..e424723450680 100644 --- a/google/cloud/dataproc/v1/autoscaling_policy_connection.h +++ b/google/cloud/dataproc/v1/autoscaling_policy_connection.h @@ -217,6 +217,27 @@ 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..ad66f2d4de817 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,45 @@ 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; +} + +Idempotency AutoscalingPolicyServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AutoscalingPolicyServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +AutoscalingPolicyServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency +AutoscalingPolicyServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..16474827e5bc3 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -54,6 +56,27 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..7eb25258db993 100644 --- a/google/cloud/dataproc/v1/batch_controller_client.cc +++ b/google/cloud/dataproc/v1/batch_controller_client.cc @@ -122,6 +122,84 @@ 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); +} + +StreamRange +BatchControllerClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +BatchControllerClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr BatchControllerClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr BatchControllerClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status BatchControllerClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status BatchControllerClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status BatchControllerClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status BatchControllerClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..a9d652ce99295 100644 --- a/google/cloud/dataproc/v1/batch_controller_client.h +++ b/google/cloud/dataproc/v1/batch_controller_client.h @@ -394,6 +394,388 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..937841bfdaf7c 100644 --- a/google/cloud/dataproc/v1/batch_controller_connection.cc +++ b/google/cloud/dataproc/v1/batch_controller_connection.cc @@ -78,6 +78,46 @@ 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"); +} + +StreamRange +BatchControllerConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +BatchControllerConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status BatchControllerConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status BatchControllerConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeBatchControllerConnection( std::string const& location, Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..37c6ead61f9e7 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,42 @@ 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; +} + +Idempotency BatchControllerConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency BatchControllerConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency BatchControllerConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency BatchControllerConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..944402f868bf5 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -48,6 +50,27 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..cf38c6b77dd09 100644 --- a/google/cloud/dataproc/v1/cluster_controller_client.cc +++ b/google/cloud/dataproc/v1/cluster_controller_client.cc @@ -324,6 +324,85 @@ 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); +} + +StreamRange +ClusterControllerClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +ClusterControllerClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr ClusterControllerClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr ClusterControllerClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status ClusterControllerClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status ClusterControllerClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status ClusterControllerClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status ClusterControllerClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..d0e21dd85ceba 100644 --- a/google/cloud/dataproc/v1/cluster_controller_client.h +++ b/google/cloud/dataproc/v1/cluster_controller_client.h @@ -941,6 +941,388 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..1079556e8cb1f 100644 --- a/google/cloud/dataproc/v1/cluster_controller_connection.cc +++ b/google/cloud/dataproc/v1/cluster_controller_connection.cc @@ -190,6 +190,46 @@ 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"); +} + +StreamRange +ClusterControllerConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +ClusterControllerConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ClusterControllerConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ClusterControllerConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeClusterControllerConnection( std::string const& location, Options options) { internal::CheckExpectedOptions> 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..39ae779c583b0 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,42 @@ 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; +} + +Idempotency ClusterControllerConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ClusterControllerConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ClusterControllerConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency ClusterControllerConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..c2f7b2bc1cb3d 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -60,6 +62,27 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..49b27322226d7 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,65 @@ 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); +} + +StatusOr +AutoscalingPolicyServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +AutoscalingPolicyServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status AutoscalingPolicyServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status AutoscalingPolicyServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..a070c5aa7659d 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..0ed237c1fd580 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,122 @@ 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__); +} + +StreamRange +AutoscalingPolicyServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +AutoscalingPolicyServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status AutoscalingPolicyServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status AutoscalingPolicyServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..d8b0ce699865e 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,27 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..0c2b8302455db 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,86 @@ 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_); +} + +StatusOr +AutoscalingPolicyServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AutoscalingPolicyServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AutoscalingPolicyServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AutoscalingPolicyServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..25058834028dc 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..62406e0ec4f0a 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,70 @@ 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); +} + +StatusOr +AutoscalingPolicyServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +AutoscalingPolicyServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status AutoscalingPolicyServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status AutoscalingPolicyServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..b65e030bd3d7c 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..ed499879af17f 100644 --- a/google/cloud/dataproc/v1/internal/autoscaling_policy_stub.cc +++ b/google/cloud/dataproc/v1/internal/autoscaling_policy_stub.cc @@ -97,6 +97,89 @@ 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; +} + +StatusOr +DefaultAutoscalingPolicyServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAutoscalingPolicyServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultAutoscalingPolicyServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultAutoscalingPolicyServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..f962b8a63191c 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,35 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultAutoscalingPolicyServiceStub @@ -71,8 +102,13 @@ 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 + operations_stub, + std::unique_ptr iampolicy_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)) {} StatusOr CreateAutoscalingPolicy( @@ -102,10 +138,41 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr< google::cloud::dataproc::v1::AutoscalingPolicyService::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..eda924a21d7dc 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -45,9 +47,13 @@ CreateDefaultAutoscalingPolicyServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dataproc::v1::AutoscalingPolicyService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..a1d6409113248 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,69 @@ 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)); +} + +StreamRange +AutoscalingPolicyServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dataproc_v1::AutoscalingPolicyServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AutoscalingPolicyServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::AutoscalingPolicyServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status AutoscalingPolicyServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::AutoscalingPolicyServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status AutoscalingPolicyServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::AutoscalingPolicyServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..03f05d5deb716 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,27 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..79467ae253115 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,89 @@ 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)); +} + +StatusOr +AutoscalingPolicyServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.AutoscalingPolicyService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +AutoscalingPolicyServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.AutoscalingPolicyService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status AutoscalingPolicyServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.AutoscalingPolicyService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status AutoscalingPolicyServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.AutoscalingPolicyService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..43b4cfa209acf 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..c1cc8ded95c75 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,64 @@ 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); +} + +StatusOr +BatchControllerAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr BatchControllerAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status BatchControllerAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status BatchControllerAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..bc234de0ea28c 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..9666d11de2ed0 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,119 @@ 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__); +} + +StreamRange +BatchControllerConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +BatchControllerConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status BatchControllerConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status BatchControllerConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..8073eebe8c34f 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,27 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..9c269cdafc1b2 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,85 @@ 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_); +} + +StatusOr +BatchControllerLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr BatchControllerLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status BatchControllerLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status BatchControllerLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..c80938dee2e18 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..56887d7672e68 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,67 @@ 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); +} + +StatusOr +BatchControllerMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr BatchControllerMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status BatchControllerMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status BatchControllerMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..09aa631709906 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..4f263f05fc429 100644 --- a/google/cloud/dataproc/v1/internal/batch_controller_stub.cc +++ b/google/cloud/dataproc/v1/internal/batch_controller_stub.cc @@ -96,6 +96,87 @@ 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; +} + +StatusOr +DefaultBatchControllerStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultBatchControllerStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultBatchControllerStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultBatchControllerStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..e5a3e369f8a60 100644 --- a/google/cloud/dataproc/v1/internal/batch_controller_stub.h +++ b/google/cloud/dataproc/v1/internal/batch_controller_stub.h @@ -26,6 +26,7 @@ #include "google/cloud/version.h" #include #include +#include #include #include #include @@ -62,6 +63,35 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -81,9 +111,15 @@ class DefaultBatchControllerStub : public BatchControllerStub { std::unique_ptr< google::cloud::dataproc::v1::BatchController::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + operations_(std::move(operations)) {} future> AsyncCreateBatch( google::cloud::CompletionQueue& cq, @@ -107,6 +143,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -122,6 +186,9 @@ class DefaultBatchControllerStub : public BatchControllerStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..28936d91b5648 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultBatchControllerStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dataproc::v1::BatchController::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..71043b5bfda2b 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,69 @@ 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)); +} + +StreamRange +BatchControllerTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dataproc_v1::BatchControllerConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +BatchControllerTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::BatchControllerConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status BatchControllerTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::BatchControllerConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status BatchControllerTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::BatchControllerConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..1c224784bfc1a 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,27 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..41d547c3d735e 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,86 @@ 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)); +} + +StatusOr +BatchControllerTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataproc.v1.BatchController", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +BatchControllerTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataproc.v1.BatchController", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status BatchControllerTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataproc.v1.BatchController", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status BatchControllerTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataproc.v1.BatchController", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..a7b7a1e90b022 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..a6db7ae55da62 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,64 @@ 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); +} + +StatusOr +ClusterControllerAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr ClusterControllerAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status ClusterControllerAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status ClusterControllerAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..439ec36437505 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..a632e85dc69ad 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,119 @@ 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__); +} + +StreamRange +ClusterControllerConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ClusterControllerConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ClusterControllerConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ClusterControllerConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..cf57a2f758e78 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,27 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..0dfb7d8de30ef 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,85 @@ 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_); +} + +StatusOr +ClusterControllerLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ClusterControllerLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ClusterControllerLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ClusterControllerLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..8a943fa61c232 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..5010d64ed38a6 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,68 @@ 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); +} + +StatusOr +ClusterControllerMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +ClusterControllerMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status ClusterControllerMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status ClusterControllerMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..5911c4fae85ca 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..c82fd7a45fef6 100644 --- a/google/cloud/dataproc/v1/internal/cluster_controller_stub.cc +++ b/google/cloud/dataproc/v1/internal/cluster_controller_stub.cc @@ -235,6 +235,87 @@ 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; +} + +StatusOr +DefaultClusterControllerStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultClusterControllerStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultClusterControllerStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultClusterControllerStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..aeee16815937f 100644 --- a/google/cloud/dataproc/v1/internal/cluster_controller_stub.h +++ b/google/cloud/dataproc/v1/internal/cluster_controller_stub.h @@ -26,6 +26,7 @@ #include "google/cloud/version.h" #include #include +#include #include #include #include @@ -108,6 +109,35 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -127,9 +157,15 @@ class DefaultClusterControllerStub : public ClusterControllerStub { std::unique_ptr< google::cloud::dataproc::v1::ClusterController::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + operations_(std::move(operations)) {} future> AsyncCreateCluster( google::cloud::CompletionQueue& cq, @@ -207,6 +243,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -222,6 +286,9 @@ class DefaultClusterControllerStub : public ClusterControllerStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..a2d296e814182 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultClusterControllerStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dataproc::v1::ClusterController::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..6cfacd0d78bf3 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,69 @@ 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)); +} + +StreamRange +ClusterControllerTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dataproc_v1::ClusterControllerConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ClusterControllerTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::ClusterControllerConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status ClusterControllerTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::ClusterControllerConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status ClusterControllerTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::ClusterControllerConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..39e7f150022d8 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,27 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..667e86c5e8cfb 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,86 @@ 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)); +} + +StatusOr +ClusterControllerTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.ClusterController", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +ClusterControllerTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.ClusterController", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status ClusterControllerTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.ClusterController", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status ClusterControllerTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.ClusterController", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..5aff2cb6c8891 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..a8e8c9d3ee654 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,64 @@ 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); +} + +StatusOr +JobControllerAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr JobControllerAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status JobControllerAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status JobControllerAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..2bd9967d5a427 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..768f4ffdc1ac4 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,119 @@ 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__); +} + +StreamRange +JobControllerConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +JobControllerConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status JobControllerConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status JobControllerConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..f9ab1f12f364f 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,27 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..305bfdc7f6779 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,85 @@ 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_); +} + +StatusOr +JobControllerLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr JobControllerLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status JobControllerLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status JobControllerLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..cc06e148689da 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..9765d358a7f91 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,67 @@ 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); +} + +StatusOr +JobControllerMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr JobControllerMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status JobControllerMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status JobControllerMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..bb9dcc6ab5d7d 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..3140dd211fea3 100644 --- a/google/cloud/dataproc/v1/internal/job_controller_stub.cc +++ b/google/cloud/dataproc/v1/internal/job_controller_stub.cc @@ -128,6 +128,86 @@ 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; +} + +StatusOr +DefaultJobControllerStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultJobControllerStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultJobControllerStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultJobControllerStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..11b6d09752828 100644 --- a/google/cloud/dataproc/v1/internal/job_controller_stub.h +++ b/google/cloud/dataproc/v1/internal/job_controller_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -73,6 +74,35 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -91,9 +121,15 @@ class DefaultJobControllerStub : public JobControllerStub { DefaultJobControllerStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + operations_(std::move(operations)) {} StatusOr SubmitJob( grpc::ClientContext& context, Options const& options, @@ -129,6 +165,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -144,6 +208,9 @@ class DefaultJobControllerStub : public JobControllerStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..1bbd0716b6858 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultJobControllerStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dataproc::v1::JobController::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..5e2daa808e3c3 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,67 @@ 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)); +} + +StreamRange +JobControllerTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dataproc_v1::JobControllerConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +JobControllerTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("dataproc_v1::JobControllerConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status JobControllerTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::JobControllerConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status JobControllerTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::JobControllerConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..66ffbabed5b78 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,27 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..3107041fd1872 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,85 @@ 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)); +} + +StatusOr +JobControllerTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataproc.v1.JobController", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr JobControllerTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataproc.v1.JobController", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status JobControllerTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataproc.v1.JobController", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status JobControllerTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataproc.v1.JobController", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..28ffa483c5513 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..76b2bf2bc5b24 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,64 @@ 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); +} + +StatusOr +NodeGroupControllerAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr NodeGroupControllerAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status NodeGroupControllerAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status NodeGroupControllerAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..17a245666056f 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..daa2e553fdbb9 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 @@ -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 @@ -264,6 +265,121 @@ 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__); +} + +StreamRange +NodeGroupControllerConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +NodeGroupControllerConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status NodeGroupControllerConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status NodeGroupControllerConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..7943478eb9c89 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 @@ -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 @@ -78,6 +79,27 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..7db9bd2346aa3 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,86 @@ 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_); +} + +StatusOr +NodeGroupControllerLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +NodeGroupControllerLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status NodeGroupControllerLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status NodeGroupControllerLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..8fb3ad669a139 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..ad077d8c1dc71 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,68 @@ 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); +} + +StatusOr +NodeGroupControllerMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +NodeGroupControllerMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status NodeGroupControllerMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status NodeGroupControllerMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..37ff1a33ac928 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..cc14770d4b59f 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,87 @@ 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; +} + +StatusOr +DefaultNodeGroupControllerStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultNodeGroupControllerStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultNodeGroupControllerStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultNodeGroupControllerStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..e970f7a9ecc95 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,7 @@ #include "google/cloud/version.h" #include #include +#include #include #include #include @@ -63,6 +64,35 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -82,9 +112,15 @@ class DefaultNodeGroupControllerStub : public NodeGroupControllerStub { std::unique_ptr< google::cloud::dataproc::v1::NodeGroupController::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + operations_(std::move(operations)) {} future> AsyncCreateNodeGroup( google::cloud::CompletionQueue& cq, @@ -114,6 +150,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -130,6 +194,9 @@ class DefaultNodeGroupControllerStub : public NodeGroupControllerStub { std::unique_ptr< google::cloud::dataproc::v1::NodeGroupController::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..da0c8d12de2eb 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultNodeGroupControllerStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dataproc::v1::NodeGroupController::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..6c062b8815e9b 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 @@ -18,6 +18,7 @@ #include "google/cloud/dataproc/v1/internal/node_group_controller_tracing_connection.h" #include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" #include #include @@ -99,6 +100,69 @@ 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)); +} + +StreamRange +NodeGroupControllerTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dataproc_v1::NodeGroupControllerConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +NodeGroupControllerTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::NodeGroupControllerConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status NodeGroupControllerTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::NodeGroupControllerConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status NodeGroupControllerTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::NodeGroupControllerConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..54cce1456d2e6 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,27 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..71ce41ea885d0 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,86 @@ 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)); +} + +StatusOr +NodeGroupControllerTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.NodeGroupController", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +NodeGroupControllerTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.NodeGroupController", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status NodeGroupControllerTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.NodeGroupController", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status NodeGroupControllerTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.NodeGroupController", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..1220209b98671 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..70f81ebf7fa0e 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,64 @@ 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); +} + +StatusOr +SessionControllerAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr SessionControllerAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status SessionControllerAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status SessionControllerAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..8d01076b0e2da 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..8e008db18b480 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,119 @@ 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__); +} + +StreamRange +SessionControllerConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +SessionControllerConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status SessionControllerConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status SessionControllerConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..0a2f18128008e 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,27 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..3c1cfe37af4b6 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,85 @@ 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_); +} + +StatusOr +SessionControllerLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr SessionControllerLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status SessionControllerLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status SessionControllerLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..122cd5f867d3a 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..19b878b1fde04 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,68 @@ 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); +} + +StatusOr +SessionControllerMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +SessionControllerMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status SessionControllerMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status SessionControllerMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..3e688938cb4d8 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..257c4905a32cd 100644 --- a/google/cloud/dataproc/v1/internal/session_controller_stub.cc +++ b/google/cloud/dataproc/v1/internal/session_controller_stub.cc @@ -146,6 +146,87 @@ 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; +} + +StatusOr +DefaultSessionControllerStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultSessionControllerStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultSessionControllerStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultSessionControllerStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..c280191f1325c 100644 --- a/google/cloud/dataproc/v1/internal/session_controller_stub.h +++ b/google/cloud/dataproc/v1/internal/session_controller_stub.h @@ -26,6 +26,7 @@ #include "google/cloud/version.h" #include #include +#include #include #include #include @@ -79,6 +80,35 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -98,9 +128,15 @@ class DefaultSessionControllerStub : public SessionControllerStub { std::unique_ptr< google::cloud::dataproc::v1::SessionController::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + operations_(std::move(operations)) {} future> AsyncCreateSession( google::cloud::CompletionQueue& cq, @@ -146,6 +182,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -161,6 +225,9 @@ class DefaultSessionControllerStub : public SessionControllerStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..c50cbb1484750 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultSessionControllerStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dataproc::v1::SessionController::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..274a7e8f4f539 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,69 @@ 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)); +} + +StreamRange +SessionControllerTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dataproc_v1::SessionControllerConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +SessionControllerTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::SessionControllerConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status SessionControllerTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::SessionControllerConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status SessionControllerTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::SessionControllerConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..3af4be9d7533e 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,27 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..60757189b9a75 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,86 @@ 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)); +} + +StatusOr +SessionControllerTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.SessionController", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +SessionControllerTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.SessionController", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status SessionControllerTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.SessionController", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status SessionControllerTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.SessionController", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..65018a37f381c 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..0147315f67049 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,65 @@ 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); +} + +StatusOr +SessionTemplateControllerAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +SessionTemplateControllerAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status SessionTemplateControllerAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status SessionTemplateControllerAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..7275f8b862b34 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..9d1f0b91fb62e 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,122 @@ 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__); +} + +StreamRange +SessionTemplateControllerConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +SessionTemplateControllerConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status SessionTemplateControllerConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status SessionTemplateControllerConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..439b7aa878847 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,27 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..ae438c8262458 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,88 @@ 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_); +} + +StatusOr +SessionTemplateControllerLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +SessionTemplateControllerLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status SessionTemplateControllerLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status SessionTemplateControllerLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..75da20626f4f2 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..4ea4f02821ed5 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,70 @@ 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); +} + +StatusOr +SessionTemplateControllerMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +SessionTemplateControllerMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status SessionTemplateControllerMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status SessionTemplateControllerMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..86019ed3fbb9f 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..139fab44f6140 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,89 @@ 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; +} + +StatusOr +DefaultSessionTemplateControllerStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultSessionTemplateControllerStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultSessionTemplateControllerStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultSessionTemplateControllerStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..dc0a9d4b809fa 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,35 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultSessionTemplateControllerStub @@ -71,8 +102,13 @@ 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 + operations_stub, + std::unique_ptr iampolicy_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)) {} StatusOr CreateSessionTemplate( grpc::ClientContext& context, Options const& options, @@ -100,10 +136,41 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr< google::cloud::dataproc::v1::SessionTemplateController::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..26a7268b8513f 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -45,9 +47,13 @@ CreateDefaultSessionTemplateControllerStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dataproc::v1::SessionTemplateController::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..bc93ce5f179b5 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,69 @@ 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)); +} + +StreamRange +SessionTemplateControllerTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dataproc_v1::SessionTemplateControllerConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +SessionTemplateControllerTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::SessionTemplateControllerConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status SessionTemplateControllerTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::SessionTemplateControllerConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status SessionTemplateControllerTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::SessionTemplateControllerConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..405b531b22470 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,27 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..ed797220cb2f8 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,89 @@ 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)); +} + +StatusOr +SessionTemplateControllerTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.SessionTemplateController", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +SessionTemplateControllerTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.SessionTemplateController", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status SessionTemplateControllerTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.SessionTemplateController", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status SessionTemplateControllerTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.SessionTemplateController", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..02ed759e87ca9 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..898fe096026b0 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,65 @@ 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); +} + +StatusOr +WorkflowTemplateServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +WorkflowTemplateServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status WorkflowTemplateServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status WorkflowTemplateServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..61ef2f7f40646 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..6c2a323853190 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,121 @@ 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__); +} + +StreamRange +WorkflowTemplateServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +WorkflowTemplateServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status WorkflowTemplateServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status WorkflowTemplateServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..9a694690d314c 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,27 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..9792c046b33a0 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,86 @@ 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_); +} + +StatusOr +WorkflowTemplateServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +WorkflowTemplateServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status WorkflowTemplateServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status WorkflowTemplateServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..8e98b02c450d5 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..5aef8d0bf8caa 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,68 @@ 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); +} + +StatusOr +WorkflowTemplateServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +WorkflowTemplateServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status WorkflowTemplateServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status WorkflowTemplateServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..df9ccfa612a2e 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..4c450596558e2 100644 --- a/google/cloud/dataproc/v1/internal/workflow_template_stub.cc +++ b/google/cloud/dataproc/v1/internal/workflow_template_stub.cc @@ -164,6 +164,89 @@ 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; +} + +StatusOr +DefaultWorkflowTemplateServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultWorkflowTemplateServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultWorkflowTemplateServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultWorkflowTemplateServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..35fac5984564d 100644 --- a/google/cloud/dataproc/v1/internal/workflow_template_stub.h +++ b/google/cloud/dataproc/v1/internal/workflow_template_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -94,6 +95,35 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -113,9 +143,15 @@ class DefaultWorkflowTemplateServiceStub : public WorkflowTemplateServiceStub { std::unique_ptr< google::cloud::dataproc::v1::WorkflowTemplateService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + operations_(std::move(operations)) {} StatusOr CreateWorkflowTemplate( @@ -171,6 +207,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -187,6 +251,9 @@ class DefaultWorkflowTemplateServiceStub : public WorkflowTemplateServiceStub { std::unique_ptr< google::cloud::dataproc::v1::WorkflowTemplateService::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..e005aa76c358b 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -45,9 +47,13 @@ CreateDefaultWorkflowTemplateServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dataproc::v1::WorkflowTemplateService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..7be38e142f184 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,69 @@ 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)); +} + +StreamRange +WorkflowTemplateServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dataproc_v1::WorkflowTemplateServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +WorkflowTemplateServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::WorkflowTemplateServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status WorkflowTemplateServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::WorkflowTemplateServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status WorkflowTemplateServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::WorkflowTemplateServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..46d0d65857234 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,27 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..36082746dae86 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,88 @@ 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)); +} + +StatusOr +WorkflowTemplateServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.WorkflowTemplateService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +WorkflowTemplateServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.WorkflowTemplateService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status WorkflowTemplateServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.WorkflowTemplateService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status WorkflowTemplateServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.WorkflowTemplateService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..6e3a6c6a65126 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,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..88df32d82ed8b 100644 --- a/google/cloud/dataproc/v1/job_controller_client.cc +++ b/google/cloud/dataproc/v1/job_controller_client.cc @@ -183,6 +183,82 @@ 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); +} + +StreamRange JobControllerClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange JobControllerClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr JobControllerClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr JobControllerClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status JobControllerClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status JobControllerClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status JobControllerClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status JobControllerClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..0bee102a16b1a 100644 --- a/google/cloud/dataproc/v1/job_controller_client.h +++ b/google/cloud/dataproc/v1/job_controller_client.h @@ -604,6 +604,388 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..32dc7e5f95a5e 100644 --- a/google/cloud/dataproc/v1/job_controller_connection.cc +++ b/google/cloud/dataproc/v1/job_controller_connection.cc @@ -93,6 +93,45 @@ 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"); +} + +StreamRange +JobControllerConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr JobControllerConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status JobControllerConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status JobControllerConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeJobControllerConnection( std::string const& location, Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..0f0fc835c290a 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,42 @@ 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; +} + +Idempotency JobControllerConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency JobControllerConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency JobControllerConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency JobControllerConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..c21f42ad595f0 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -57,6 +59,27 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..73fa64b4f0f0c 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,34 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..01150c08e1074 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,34 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..4a7703cef19bb 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,34 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..00ade431b8b9b 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,34 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..a49eddd926423 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,34 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..ee372ed318559 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,34 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..4d83a2658fca6 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,34 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..35b936b0d70fb 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,34 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..fb1d95a20ce32 100644 --- a/google/cloud/dataproc/v1/node_group_controller_client.cc +++ b/google/cloud/dataproc/v1/node_group_controller_client.cc @@ -142,6 +142,86 @@ 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); +} + +StreamRange +NodeGroupControllerClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +NodeGroupControllerClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +NodeGroupControllerClient::GetOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +NodeGroupControllerClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status NodeGroupControllerClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status NodeGroupControllerClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status NodeGroupControllerClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status NodeGroupControllerClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..9547e00890ce2 100644 --- a/google/cloud/dataproc/v1/node_group_controller_client.h +++ b/google/cloud/dataproc/v1/node_group_controller_client.h @@ -404,6 +404,388 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..bec79017a4787 100644 --- a/google/cloud/dataproc/v1/node_group_controller_connection.cc +++ b/google/cloud/dataproc/v1/node_group_controller_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 @@ -89,6 +90,46 @@ 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"); +} + +StreamRange +NodeGroupControllerConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +NodeGroupControllerConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status NodeGroupControllerConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status NodeGroupControllerConnection::CancelOperation( + google::longrunning::CancelOperationRequest 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..e1ea0c480821e 100644 --- a/google/cloud/dataproc/v1/node_group_controller_connection.h +++ b/google/cloud/dataproc/v1/node_group_controller_connection.h @@ -28,6 +28,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 @@ -214,6 +215,27 @@ 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..82828feb5c2f7 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,42 @@ 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; +} + +Idempotency NodeGroupControllerConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency NodeGroupControllerConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency NodeGroupControllerConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency NodeGroupControllerConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..2005d1a34183c 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -45,6 +47,27 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..3a55efc5c214a 100644 --- a/google/cloud/dataproc/v1/session_controller_client.cc +++ b/google/cloud/dataproc/v1/session_controller_client.cc @@ -192,6 +192,85 @@ 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); +} + +StreamRange +SessionControllerClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +SessionControllerClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr SessionControllerClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr SessionControllerClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status SessionControllerClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status SessionControllerClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status SessionControllerClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status SessionControllerClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..1f048ea6958e9 100644 --- a/google/cloud/dataproc/v1/session_controller_client.h +++ b/google/cloud/dataproc/v1/session_controller_client.h @@ -567,6 +567,388 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..ad14ef3992168 100644 --- a/google/cloud/dataproc/v1/session_controller_connection.cc +++ b/google/cloud/dataproc/v1/session_controller_connection.cc @@ -121,6 +121,46 @@ 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"); +} + +StreamRange +SessionControllerConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +SessionControllerConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status SessionControllerConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status SessionControllerConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSessionControllerConnection( std::string const& location, Options options) { internal::CheckExpectedOptions> 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..4a45dee6576b0 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,42 @@ 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; +} + +Idempotency SessionControllerConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SessionControllerConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency SessionControllerConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency SessionControllerConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..2923d64dc5b06 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -51,6 +53,27 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..8d990f53767c2 100644 --- a/google/cloud/dataproc/v1/session_template_controller_client.cc +++ b/google/cloud/dataproc/v1/session_template_controller_client.cc @@ -120,6 +120,87 @@ 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); +} + +StreamRange +SessionTemplateControllerClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +SessionTemplateControllerClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +SessionTemplateControllerClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +SessionTemplateControllerClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status SessionTemplateControllerClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status SessionTemplateControllerClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status SessionTemplateControllerClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status SessionTemplateControllerClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..3b0788157bcc9 100644 --- a/google/cloud/dataproc/v1/session_template_controller_client.h +++ b/google/cloud/dataproc/v1/session_template_controller_client.h @@ -386,6 +386,388 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..aaf5a413b45ee 100644 --- a/google/cloud/dataproc/v1/session_template_controller_connection.cc +++ b/google/cloud/dataproc/v1/session_template_controller_connection.cc @@ -70,6 +70,48 @@ 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"); +} + +StreamRange +SessionTemplateControllerConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +SessionTemplateControllerConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status SessionTemplateControllerConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status SessionTemplateControllerConnection::CancelOperation( + google::longrunning::CancelOperationRequest 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..688ff76299b60 100644 --- a/google/cloud/dataproc/v1/session_template_controller_connection.h +++ b/google/cloud/dataproc/v1/session_template_controller_connection.h @@ -215,6 +215,27 @@ 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..76a470a9e13af 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,46 @@ 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; +} + +Idempotency +SessionTemplateControllerConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SessionTemplateControllerConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +SessionTemplateControllerConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency +SessionTemplateControllerConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..2a641c638f8e1 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -51,6 +53,27 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..25655b9999af8 100644 --- a/google/cloud/dataproc/v1/workflow_template_client.cc +++ b/google/cloud/dataproc/v1/workflow_template_client.cc @@ -235,6 +235,87 @@ 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); +} + +StreamRange +WorkflowTemplateServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +WorkflowTemplateServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +WorkflowTemplateServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +WorkflowTemplateServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status WorkflowTemplateServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status WorkflowTemplateServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status WorkflowTemplateServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status WorkflowTemplateServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..261f7215a7424 100644 --- a/google/cloud/dataproc/v1/workflow_template_client.h +++ b/google/cloud/dataproc/v1/workflow_template_client.h @@ -890,6 +890,388 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..ceb5b0253ab9f 100644 --- a/google/cloud/dataproc/v1/workflow_template_connection.cc +++ b/google/cloud/dataproc/v1/workflow_template_connection.cc @@ -119,6 +119,48 @@ 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"); +} + +StreamRange +WorkflowTemplateServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +WorkflowTemplateServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status WorkflowTemplateServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status WorkflowTemplateServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest 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..44ed8e1cfbe07 100644 --- a/google/cloud/dataproc/v1/workflow_template_connection.h +++ b/google/cloud/dataproc/v1/workflow_template_connection.h @@ -242,6 +242,27 @@ 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..ee769a3588f79 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,43 @@ 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; +} + +Idempotency WorkflowTemplateServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency WorkflowTemplateServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency WorkflowTemplateServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency WorkflowTemplateServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..86c46bc8cac38 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -62,6 +64,27 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/datastore/admin/v1/datastore_admin_client.cc b/google/cloud/datastore/admin/v1/datastore_admin_client.cc index c8c061205cfbf..6c5e8ebaf8277 100644 --- a/google/cloud/datastore/admin/v1/datastore_admin_client.cc +++ b/google/cloud/datastore/admin/v1/datastore_admin_client.cc @@ -196,6 +196,65 @@ DatastoreAdminClient::ListIndexes( return connection_->ListIndexes(std::move(request)); } +StreamRange +DatastoreAdminClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +DatastoreAdminClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr DatastoreAdminClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr DatastoreAdminClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status DatastoreAdminClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status DatastoreAdminClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status DatastoreAdminClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status DatastoreAdminClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace datastore_admin_v1 } // namespace cloud diff --git a/google/cloud/datastore/admin/v1/datastore_admin_client.h b/google/cloud/datastore/admin/v1/datastore_admin_client.h index 498d4c28deaa7..75eeaee53e4a8 100644 --- a/google/cloud/datastore/admin/v1/datastore_admin_client.h +++ b/google/cloud/datastore/admin/v1/datastore_admin_client.h @@ -674,6 +674,286 @@ class DatastoreAdminClient { google::datastore::admin::v1::ListIndexesRequest request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/datastore/admin/v1/datastore_admin_connection.cc b/google/cloud/datastore/admin/v1/datastore_admin_connection.cc index 6dcddcdd77a3e..82608c19bcd51 100644 --- a/google/cloud/datastore/admin/v1/datastore_admin_connection.cc +++ b/google/cloud/datastore/admin/v1/datastore_admin_connection.cc @@ -140,6 +140,29 @@ DatastoreAdminConnection::ListIndexes( StreamRange>(); } +StreamRange +DatastoreAdminConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr DatastoreAdminConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DatastoreAdminConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DatastoreAdminConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDatastoreAdminConnection( Options options) { internal::CheckExpectedOptions ListIndexes( google::datastore::admin::v1::ListIndexesRequest request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/datastore/admin/v1/datastore_admin_connection_idempotency_policy.cc b/google/cloud/datastore/admin/v1/datastore_admin_connection_idempotency_policy.cc index d17943c98a147..00e8846a3ea24 100644 --- a/google/cloud/datastore/admin/v1/datastore_admin_connection_idempotency_policy.cc +++ b/google/cloud/datastore/admin/v1/datastore_admin_connection_idempotency_policy.cc @@ -64,6 +64,26 @@ Idempotency DatastoreAdminConnectionIdempotencyPolicy::ListIndexes( return Idempotency::kIdempotent; } +Idempotency DatastoreAdminConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DatastoreAdminConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DatastoreAdminConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency DatastoreAdminConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultDatastoreAdminConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/datastore/admin/v1/datastore_admin_connection_idempotency_policy.h b/google/cloud/datastore/admin/v1/datastore_admin_connection_idempotency_policy.h index 2b0693ed4b881..d78abe1cd49ba 100644 --- a/google/cloud/datastore/admin/v1/datastore_admin_connection_idempotency_policy.h +++ b/google/cloud/datastore/admin/v1/datastore_admin_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,18 @@ class DatastoreAdminConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListIndexes( google::datastore::admin::v1::ListIndexesRequest request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/datastore/admin/v1/internal/datastore_admin_auth_decorator.cc b/google/cloud/datastore/admin/v1/internal/datastore_admin_auth_decorator.cc index f88c236280a2e..50fc0ee8b3c64 100644 --- a/google/cloud/datastore/admin/v1/internal/datastore_admin_auth_decorator.cc +++ b/google/cloud/datastore/admin/v1/internal/datastore_admin_auth_decorator.cc @@ -160,6 +160,39 @@ DatastoreAdminAuth::ListIndexes( return child_->ListIndexes(context, options, request); } +StatusOr +DatastoreAdminAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr DatastoreAdminAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status DatastoreAdminAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status DatastoreAdminAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + future> DatastoreAdminAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/datastore/admin/v1/internal/datastore_admin_auth_decorator.h b/google/cloud/datastore/admin/v1/internal/datastore_admin_auth_decorator.h index 6939e15de883b..4c4c2666859b1 100644 --- a/google/cloud/datastore/admin/v1/internal/datastore_admin_auth_decorator.h +++ b/google/cloud/datastore/admin/v1/internal/datastore_admin_auth_decorator.h @@ -91,6 +91,22 @@ class DatastoreAdminAuth : public DatastoreAdminStub { grpc::ClientContext& context, Options const& options, google::datastore::admin::v1::ListIndexesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/datastore/admin/v1/internal/datastore_admin_connection_impl.cc b/google/cloud/datastore/admin/v1/internal/datastore_admin_connection_impl.cc index ae74801db3468..d3acc9f58bbe9 100644 --- a/google/cloud/datastore/admin/v1/internal/datastore_admin_connection_impl.cc +++ b/google/cloud/datastore/admin/v1/internal/datastore_admin_connection_impl.cc @@ -484,6 +484,79 @@ DatastoreAdminConnectionImpl::ListIndexes( }); } +StreamRange +DatastoreAdminConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DatastoreAdminConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DatastoreAdminConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DatastoreAdminConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace datastore_admin_v1_internal } // namespace cloud diff --git a/google/cloud/datastore/admin/v1/internal/datastore_admin_connection_impl.h b/google/cloud/datastore/admin/v1/internal/datastore_admin_connection_impl.h index 0064e4077b337..f541a356bc2b6 100644 --- a/google/cloud/datastore/admin/v1/internal/datastore_admin_connection_impl.h +++ b/google/cloud/datastore/admin/v1/internal/datastore_admin_connection_impl.h @@ -102,6 +102,18 @@ class DatastoreAdminConnectionImpl StreamRange ListIndexes( google::datastore::admin::v1::ListIndexesRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/datastore/admin/v1/internal/datastore_admin_logging_decorator.cc b/google/cloud/datastore/admin/v1/internal/datastore_admin_logging_decorator.cc index 16a805157e7d6..0e6b75596b449 100644 --- a/google/cloud/datastore/admin/v1/internal/datastore_admin_logging_decorator.cc +++ b/google/cloud/datastore/admin/v1/internal/datastore_admin_logging_decorator.cc @@ -178,6 +178,51 @@ DatastoreAdminLogging::ListIndexes( context, options, request, __func__, tracing_options_); } +StatusOr +DatastoreAdminLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DatastoreAdminLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DatastoreAdminLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DatastoreAdminLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> DatastoreAdminLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/datastore/admin/v1/internal/datastore_admin_logging_decorator.h b/google/cloud/datastore/admin/v1/internal/datastore_admin_logging_decorator.h index 0441e80076890..41cebc3dbde67 100644 --- a/google/cloud/datastore/admin/v1/internal/datastore_admin_logging_decorator.h +++ b/google/cloud/datastore/admin/v1/internal/datastore_admin_logging_decorator.h @@ -91,6 +91,22 @@ class DatastoreAdminLogging : public DatastoreAdminStub { grpc::ClientContext& context, Options const& options, google::datastore::admin::v1::ListIndexesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/datastore/admin/v1/internal/datastore_admin_metadata_decorator.cc b/google/cloud/datastore/admin/v1/internal/datastore_admin_metadata_decorator.cc index 8070de0ddfc7c..50fcd44fc5be0 100644 --- a/google/cloud/datastore/admin/v1/internal/datastore_admin_metadata_decorator.cc +++ b/google/cloud/datastore/admin/v1/internal/datastore_admin_metadata_decorator.cc @@ -154,6 +154,39 @@ DatastoreAdminMetadata::ListIndexes( return child_->ListIndexes(context, options, request); } +StatusOr +DatastoreAdminMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr DatastoreAdminMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status DatastoreAdminMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status DatastoreAdminMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + future> DatastoreAdminMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/datastore/admin/v1/internal/datastore_admin_metadata_decorator.h b/google/cloud/datastore/admin/v1/internal/datastore_admin_metadata_decorator.h index 6f9c6554ca151..8884cb69ff0d5 100644 --- a/google/cloud/datastore/admin/v1/internal/datastore_admin_metadata_decorator.h +++ b/google/cloud/datastore/admin/v1/internal/datastore_admin_metadata_decorator.h @@ -91,6 +91,22 @@ class DatastoreAdminMetadata : public DatastoreAdminStub { grpc::ClientContext& context, Options const& options, google::datastore::admin::v1::ListIndexesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/datastore/admin/v1/internal/datastore_admin_stub.cc b/google/cloud/datastore/admin/v1/internal/datastore_admin_stub.cc index 0ca6e43ec75de..1a2e7db0a4e8e 100644 --- a/google/cloud/datastore/admin/v1/internal/datastore_admin_stub.cc +++ b/google/cloud/datastore/admin/v1/internal/datastore_admin_stub.cc @@ -173,6 +173,52 @@ DefaultDatastoreAdminStub::ListIndexes( return response; } +StatusOr +DefaultDatastoreAdminStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDatastoreAdminStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultDatastoreAdminStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultDatastoreAdminStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + future> DefaultDatastoreAdminStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/datastore/admin/v1/internal/datastore_admin_stub.h b/google/cloud/datastore/admin/v1/internal/datastore_admin_stub.h index 73531cc9b1b3e..3fb62a21aa29c 100644 --- a/google/cloud/datastore/admin/v1/internal/datastore_admin_stub.h +++ b/google/cloud/datastore/admin/v1/internal/datastore_admin_stub.h @@ -87,6 +87,22 @@ class DatastoreAdminStub { grpc::ClientContext& context, Options const& options, google::datastore::admin::v1::ListIndexesRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -106,9 +122,13 @@ class DefaultDatastoreAdminStub : public DatastoreAdminStub { std::unique_ptr< google::datastore::admin::v1::DatastoreAdmin::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} future> AsyncExportEntities( google::cloud::CompletionQueue& cq, @@ -162,6 +182,22 @@ class DefaultDatastoreAdminStub : public DatastoreAdminStub { grpc::ClientContext& context, Options const& options, google::datastore::admin::v1::ListIndexesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -177,6 +213,8 @@ class DefaultDatastoreAdminStub : public DatastoreAdminStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/datastore/admin/v1/internal/datastore_admin_stub_factory.cc b/google/cloud/datastore/admin/v1/internal/datastore_admin_stub_factory.cc index 524ef54c89831..d7bb7f99e4b12 100644 --- a/google/cloud/datastore/admin/v1/internal/datastore_admin_stub_factory.cc +++ b/google/cloud/datastore/admin/v1/internal/datastore_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 CreateDefaultDatastoreAdminStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::datastore::admin::v1::DatastoreAdmin::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/datastore/admin/v1/internal/datastore_admin_tracing_connection.cc b/google/cloud/datastore/admin/v1/internal/datastore_admin_tracing_connection.cc index 60e7646ccd355..1bf2e5beba331 100644 --- a/google/cloud/datastore/admin/v1/internal/datastore_admin_tracing_connection.cc +++ b/google/cloud/datastore/admin/v1/internal/datastore_admin_tracing_connection.cc @@ -167,6 +167,42 @@ DatastoreAdminTracingConnection::ListIndexes( std::move(span), std::move(sr)); } +StreamRange +DatastoreAdminTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "datastore_admin_v1::DatastoreAdminConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DatastoreAdminTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "datastore_admin_v1::DatastoreAdminConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status DatastoreAdminTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "datastore_admin_v1::DatastoreAdminConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status DatastoreAdminTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "datastore_admin_v1::DatastoreAdminConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/datastore/admin/v1/internal/datastore_admin_tracing_connection.h b/google/cloud/datastore/admin/v1/internal/datastore_admin_tracing_connection.h index 3b8bc95dd7a01..cc75bbe19c420 100644 --- a/google/cloud/datastore/admin/v1/internal/datastore_admin_tracing_connection.h +++ b/google/cloud/datastore/admin/v1/internal/datastore_admin_tracing_connection.h @@ -90,6 +90,18 @@ class DatastoreAdminTracingConnection StreamRange ListIndexes( google::datastore::admin::v1::ListIndexesRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/datastore/admin/v1/internal/datastore_admin_tracing_stub.cc b/google/cloud/datastore/admin/v1/internal/datastore_admin_tracing_stub.cc index 0af00fb290cdd..6206228035d4a 100644 --- a/google/cloud/datastore/admin/v1/internal/datastore_admin_tracing_stub.cc +++ b/google/cloud/datastore/admin/v1/internal/datastore_admin_tracing_stub.cc @@ -160,6 +160,52 @@ DatastoreAdminTracingStub::ListIndexes( child_->ListIndexes(context, options, request)); } +StatusOr +DatastoreAdminTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.datastore.admin.v1.DatastoreAdmin", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +DatastoreAdminTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.datastore.admin.v1.DatastoreAdmin", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status DatastoreAdminTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.datastore.admin.v1.DatastoreAdmin", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status DatastoreAdminTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.datastore.admin.v1.DatastoreAdmin", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + future> DatastoreAdminTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/datastore/admin/v1/internal/datastore_admin_tracing_stub.h b/google/cloud/datastore/admin/v1/internal/datastore_admin_tracing_stub.h index 3011afde574f4..10d180880c4e1 100644 --- a/google/cloud/datastore/admin/v1/internal/datastore_admin_tracing_stub.h +++ b/google/cloud/datastore/admin/v1/internal/datastore_admin_tracing_stub.h @@ -90,6 +90,22 @@ class DatastoreAdminTracingStub : public DatastoreAdminStub { grpc::ClientContext& context, Options const& options, google::datastore::admin::v1::ListIndexesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/datastore/admin/v1/mocks/mock_datastore_admin_connection.h b/google/cloud/datastore/admin/v1/mocks/mock_datastore_admin_connection.h index bfa67cecf4fc4..57cf46ae43fc6 100644 --- a/google/cloud/datastore/admin/v1/mocks/mock_datastore_admin_connection.h +++ b/google/cloud/datastore/admin/v1/mocks/mock_datastore_admin_connection.h @@ -208,6 +208,21 @@ class MockDatastoreAdminConnection MOCK_METHOD((StreamRange), ListIndexes, (google::datastore::admin::v1::ListIndexesRequest request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/datastore/v1/datastore_client.cc b/google/cloud/datastore/v1/datastore_client.cc index e68303a9313b9..e59ca9b794478 100644 --- a/google/cloud/datastore/v1/datastore_client.cc +++ b/google/cloud/datastore/v1/datastore_client.cc @@ -164,6 +164,61 @@ StatusOr DatastoreClient::ReserveIds( return connection_->ReserveIds(request); } +StreamRange DatastoreClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange DatastoreClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr DatastoreClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr DatastoreClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status DatastoreClient::DeleteOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status DatastoreClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status DatastoreClient::CancelOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status DatastoreClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace datastore_v1 } // namespace cloud diff --git a/google/cloud/datastore/v1/datastore_client.h b/google/cloud/datastore/v1/datastore_client.h index 9af5ea5e504e0..8717203a4c981 100644 --- a/google/cloud/datastore/v1/datastore_client.h +++ b/google/cloud/datastore/v1/datastore_client.h @@ -569,6 +569,286 @@ class DatastoreClient { google::datastore::v1::ReserveIdsRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/datastore/v1/datastore_connection.cc b/google/cloud/datastore/v1/datastore_connection.cc index 257194004f059..dd9b66bc97e84 100644 --- a/google/cloud/datastore/v1/datastore_connection.cc +++ b/google/cloud/datastore/v1/datastore_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 @@ -81,6 +82,28 @@ DatastoreConnection::ReserveIds( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange DatastoreConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr DatastoreConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DatastoreConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DatastoreConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDatastoreConnection(Options options) { internal::CheckExpectedOptions #include @@ -205,6 +206,18 @@ class DatastoreConnection { virtual StatusOr ReserveIds( google::datastore::v1::ReserveIdsRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/datastore/v1/datastore_connection_idempotency_policy.cc b/google/cloud/datastore/v1/datastore_connection_idempotency_policy.cc index 3a4416c9b4827..835d21e016bc4 100644 --- a/google/cloud/datastore/v1/datastore_connection_idempotency_policy.cc +++ b/google/cloud/datastore/v1/datastore_connection_idempotency_policy.cc @@ -74,6 +74,26 @@ Idempotency DatastoreConnectionIdempotencyPolicy::ReserveIds( return Idempotency::kNonIdempotent; } +Idempotency DatastoreConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DatastoreConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DatastoreConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency DatastoreConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultDatastoreConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/datastore/v1/datastore_connection_idempotency_policy.h b/google/cloud/datastore/v1/datastore_connection_idempotency_policy.h index 001d46f4006b7..339f92870f611 100644 --- a/google/cloud/datastore/v1/datastore_connection_idempotency_policy.h +++ b/google/cloud/datastore/v1/datastore_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,18 @@ class DatastoreConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ReserveIds( google::datastore::v1::ReserveIdsRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/datastore/v1/internal/datastore_auth_decorator.cc b/google/cloud/datastore/v1/internal/datastore_auth_decorator.cc index af91ebbb1c5ab..dc753020aefd7 100644 --- a/google/cloud/datastore/v1/internal/datastore_auth_decorator.cc +++ b/google/cloud/datastore/v1/internal/datastore_auth_decorator.cc @@ -97,6 +97,39 @@ StatusOr DatastoreAuth::ReserveIds( return child_->ReserveIds(context, options, request); } +StatusOr +DatastoreAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr DatastoreAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status DatastoreAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status DatastoreAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace datastore_v1_internal } // namespace cloud diff --git a/google/cloud/datastore/v1/internal/datastore_auth_decorator.h b/google/cloud/datastore/v1/internal/datastore_auth_decorator.h index 53da4c1f3fcd0..34ebff80e7215 100644 --- a/google/cloud/datastore/v1/internal/datastore_auth_decorator.h +++ b/google/cloud/datastore/v1/internal/datastore_auth_decorator.h @@ -71,6 +71,22 @@ class DatastoreAuth : public DatastoreStub { grpc::ClientContext& context, Options const& options, google::datastore::v1::ReserveIdsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/datastore/v1/internal/datastore_connection_impl.cc b/google/cloud/datastore/v1/internal/datastore_connection_impl.cc index d6b5ff87db548..6fb5bab45dcd6 100644 --- a/google/cloud/datastore/v1/internal/datastore_connection_impl.cc +++ b/google/cloud/datastore/v1/internal/datastore_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 @@ -167,6 +168,78 @@ DatastoreConnectionImpl::ReserveIds( *current, request, __func__); } +StreamRange +DatastoreConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr DatastoreConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DatastoreConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DatastoreConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace datastore_v1_internal } // namespace cloud diff --git a/google/cloud/datastore/v1/internal/datastore_connection_impl.h b/google/cloud/datastore/v1/internal/datastore_connection_impl.h index 265f4c88dfeaf..a0be9b7ec759d 100644 --- a/google/cloud/datastore/v1/internal/datastore_connection_impl.h +++ b/google/cloud/datastore/v1/internal/datastore_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 @@ -72,6 +73,18 @@ class DatastoreConnectionImpl : public datastore_v1::DatastoreConnection { StatusOr ReserveIds( google::datastore::v1::ReserveIdsRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/datastore/v1/internal/datastore_logging_decorator.cc b/google/cloud/datastore/v1/internal/datastore_logging_decorator.cc index 0777ee819157c..ae2aff0b08191 100644 --- a/google/cloud/datastore/v1/internal/datastore_logging_decorator.cc +++ b/google/cloud/datastore/v1/internal/datastore_logging_decorator.cc @@ -127,6 +127,51 @@ DatastoreLogging::ReserveIds( context, options, request, __func__, tracing_options_); } +StatusOr +DatastoreLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DatastoreLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DatastoreLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DatastoreLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace datastore_v1_internal } // namespace cloud diff --git a/google/cloud/datastore/v1/internal/datastore_logging_decorator.h b/google/cloud/datastore/v1/internal/datastore_logging_decorator.h index 55cd6e721ee78..3fe5acb27c08a 100644 --- a/google/cloud/datastore/v1/internal/datastore_logging_decorator.h +++ b/google/cloud/datastore/v1/internal/datastore_logging_decorator.h @@ -71,6 +71,22 @@ class DatastoreLogging : public DatastoreStub { grpc::ClientContext& context, Options const& options, google::datastore::v1::ReserveIdsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/datastore/v1/internal/datastore_metadata_decorator.cc b/google/cloud/datastore/v1/internal/datastore_metadata_decorator.cc index 4eb088e1b8a5b..28ec5bff2f177 100644 --- a/google/cloud/datastore/v1/internal/datastore_metadata_decorator.cc +++ b/google/cloud/datastore/v1/internal/datastore_metadata_decorator.cc @@ -242,6 +242,39 @@ DatastoreMetadata::ReserveIds( return child_->ReserveIds(context, options, request); } +StatusOr +DatastoreMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr DatastoreMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status DatastoreMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status DatastoreMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + void DatastoreMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/datastore/v1/internal/datastore_metadata_decorator.h b/google/cloud/datastore/v1/internal/datastore_metadata_decorator.h index aa0d520d8efa5..ed4e7e77e87cb 100644 --- a/google/cloud/datastore/v1/internal/datastore_metadata_decorator.h +++ b/google/cloud/datastore/v1/internal/datastore_metadata_decorator.h @@ -71,6 +71,22 @@ class DatastoreMetadata : public DatastoreStub { grpc::ClientContext& context, Options const& options, google::datastore::v1::ReserveIdsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/datastore/v1/internal/datastore_stub.cc b/google/cloud/datastore/v1/internal/datastore_stub.cc index ac1b499c1a2c9..0ef6628f24e0f 100644 --- a/google/cloud/datastore/v1/internal/datastore_stub.cc +++ b/google/cloud/datastore/v1/internal/datastore_stub.cc @@ -124,6 +124,51 @@ DefaultDatastoreStub::ReserveIds( return response; } +StatusOr +DefaultDatastoreStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultDatastoreStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultDatastoreStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultDatastoreStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace datastore_v1_internal } // namespace cloud diff --git a/google/cloud/datastore/v1/internal/datastore_stub.h b/google/cloud/datastore/v1/internal/datastore_stub.h index 0275882f34762..89b6d51c4d392 100644 --- a/google/cloud/datastore/v1/internal/datastore_stub.h +++ b/google/cloud/datastore/v1/internal/datastore_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -68,14 +69,33 @@ class DatastoreStub { virtual StatusOr ReserveIds( grpc::ClientContext& context, Options const& options, google::datastore::v1::ReserveIdsRequest const& request) = 0; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultDatastoreStub : public DatastoreStub { public: explicit DefaultDatastoreStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr Lookup( grpc::ClientContext& context, Options const& options, @@ -110,8 +130,26 @@ class DefaultDatastoreStub : public DatastoreStub { grpc::ClientContext& context, Options const& options, google::datastore::v1::ReserveIdsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/datastore/v1/internal/datastore_stub_factory.cc b/google/cloud/datastore/v1/internal/datastore_stub_factory.cc index 096fb1f403997..c6c447e9afe51 100644 --- a/google/cloud/datastore/v1/internal/datastore_stub_factory.cc +++ b/google/cloud/datastore/v1/internal/datastore_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -43,8 +44,10 @@ std::shared_ptr CreateDefaultDatastoreStub( auto channel = auth->CreateChannel(options.get(), internal::MakeChannelArguments(options)); auto service_grpc_stub = google::datastore::v1::Datastore::NewStub(channel); - std::shared_ptr stub = - std::make_shared(std::move(service_grpc_stub)); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); + std::shared_ptr stub = std::make_shared( + std::move(service_grpc_stub), std::move(service_operations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), std::move(stub)); diff --git a/google/cloud/datastore/v1/internal/datastore_tracing_connection.cc b/google/cloud/datastore/v1/internal/datastore_tracing_connection.cc index 5673ea01bc5f5..d4f4b8375f692 100644 --- a/google/cloud/datastore/v1/internal/datastore_tracing_connection.cc +++ b/google/cloud/datastore/v1/internal/datastore_tracing_connection.cc @@ -18,6 +18,7 @@ #include "google/cloud/datastore/v1/internal/datastore_tracing_connection.h" #include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" #include #include @@ -100,6 +101,42 @@ DatastoreTracingConnection::ReserveIds( return internal::EndSpan(*span, child_->ReserveIds(request)); } +StreamRange +DatastoreTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("datastore_v1::DatastoreConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DatastoreTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("datastore_v1::DatastoreConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status DatastoreTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = + internal::MakeSpan("datastore_v1::DatastoreConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status DatastoreTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("datastore_v1::DatastoreConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/datastore/v1/internal/datastore_tracing_connection.h b/google/cloud/datastore/v1/internal/datastore_tracing_connection.h index 6d274dda75d57..aa91ac9fad0eb 100644 --- a/google/cloud/datastore/v1/internal/datastore_tracing_connection.h +++ b/google/cloud/datastore/v1/internal/datastore_tracing_connection.h @@ -64,6 +64,18 @@ class DatastoreTracingConnection : public datastore_v1::DatastoreConnection { StatusOr ReserveIds( google::datastore::v1::ReserveIdsRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/datastore/v1/internal/datastore_tracing_stub.cc b/google/cloud/datastore/v1/internal/datastore_tracing_stub.cc index cb9a79233a407..2a2f172352050 100644 --- a/google/cloud/datastore/v1/internal/datastore_tracing_stub.cc +++ b/google/cloud/datastore/v1/internal/datastore_tracing_stub.cc @@ -123,6 +123,51 @@ DatastoreTracingStub::ReserveIds( child_->ReserveIds(context, options, request)); } +StatusOr +DatastoreTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.datastore.v1.Datastore", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr DatastoreTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.datastore.v1.Datastore", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status DatastoreTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.datastore.v1.Datastore", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status DatastoreTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.datastore.v1.Datastore", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeDatastoreTracingStub( diff --git a/google/cloud/datastore/v1/internal/datastore_tracing_stub.h b/google/cloud/datastore/v1/internal/datastore_tracing_stub.h index 68a5911c13a09..d18386e8fce74 100644 --- a/google/cloud/datastore/v1/internal/datastore_tracing_stub.h +++ b/google/cloud/datastore/v1/internal/datastore_tracing_stub.h @@ -71,6 +71,22 @@ class DatastoreTracingStub : public DatastoreStub { grpc::ClientContext& context, Options const& options, google::datastore::v1::ReserveIdsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/datastore/v1/mocks/mock_datastore_connection.h b/google/cloud/datastore/v1/mocks/mock_datastore_connection.h index ad76691d157c0..cb83334a3e56d 100644 --- a/google/cloud/datastore/v1/mocks/mock_datastore_connection.h +++ b/google/cloud/datastore/v1/mocks/mock_datastore_connection.h @@ -80,6 +80,21 @@ class MockDatastoreConnection : public datastore_v1::DatastoreConnection { MOCK_METHOD(StatusOr, ReserveIds, (google::datastore::v1::ReserveIdsRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END 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..fd66ca1406f97 100644 --- a/google/cloud/datastream/v1/datastream_client.cc +++ b/google/cloud/datastream/v1/datastream_client.cc @@ -711,6 +711,75 @@ 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); +} + +StreamRange DatastreamClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange DatastreamClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr DatastreamClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr DatastreamClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status DatastreamClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status DatastreamClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status DatastreamClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status DatastreamClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..14f08bbf4ebc4 100644 --- a/google/cloud/datastream/v1/datastream_client.h +++ b/google/cloud/datastream/v1/datastream_client.h @@ -2196,6 +2196,356 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..fbae3c181a251 100644 --- a/google/cloud/datastream/v1/datastream_connection.cc +++ b/google/cloud/datastream/v1/datastream_connection.cc @@ -362,6 +362,42 @@ 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"); +} + +StreamRange +DatastreamConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr DatastreamConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DatastreamConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DatastreamConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDatastreamConnection( Options options) { internal::CheckExpectedOptions> DeleteRoute(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..a28600a6d708f 100644 --- a/google/cloud/datastream/v1/datastream_connection_idempotency_policy.cc +++ b/google/cloud/datastream/v1/datastream_connection_idempotency_policy.cc @@ -159,6 +159,36 @@ 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; +} + +Idempotency DatastreamConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DatastreamConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DatastreamConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency DatastreamConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..56daac6a3e71b 100644 --- a/google/cloud/datastream/v1/datastream_connection_idempotency_policy.h +++ b/google/cloud/datastream/v1/datastream_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -118,6 +120,24 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..8d28a451600c8 100644 --- a/google/cloud/datastream/v1/internal/datastream_auth_decorator.cc +++ b/google/cloud/datastream/v1/internal/datastream_auth_decorator.cc @@ -462,6 +462,56 @@ 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); +} + +StatusOr +DatastreamAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr DatastreamAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status DatastreamAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status DatastreamAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..bd05cf7c6be57 100644 --- a/google/cloud/datastream/v1/internal/datastream_auth_decorator.h +++ b/google/cloud/datastream/v1/internal/datastream_auth_decorator.h @@ -237,6 +237,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..80240f821411d 100644 --- a/google/cloud/datastream/v1/internal/datastream_connection_impl.cc +++ b/google/cloud/datastream/v1/internal/datastream_connection_impl.cc @@ -1335,6 +1335,126 @@ 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__); +} + +StreamRange +DatastreamConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr DatastreamConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DatastreamConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DatastreamConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..6914a3a84cd6a 100644 --- a/google/cloud/datastream/v1/internal/datastream_connection_impl.h +++ b/google/cloud/datastream/v1/internal/datastream_connection_impl.h @@ -240,6 +240,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..de13406930ee7 100644 --- a/google/cloud/datastream/v1/internal/datastream_logging_decorator.cc +++ b/google/cloud/datastream/v1/internal/datastream_logging_decorator.cc @@ -559,6 +559,74 @@ 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_); +} + +StatusOr +DatastreamLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DatastreamLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DatastreamLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DatastreamLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..78176f3b9f339 100644 --- a/google/cloud/datastream/v1/internal/datastream_logging_decorator.h +++ b/google/cloud/datastream/v1/internal/datastream_logging_decorator.h @@ -237,6 +237,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..2e0b7395f8a0e 100644 --- a/google/cloud/datastream/v1/internal/datastream_metadata_decorator.cc +++ b/google/cloud/datastream/v1/internal/datastream_metadata_decorator.cc @@ -401,6 +401,56 @@ 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); +} + +StatusOr +DatastreamMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr DatastreamMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status DatastreamMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status DatastreamMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..c5148e3b7c56c 100644 --- a/google/cloud/datastream/v1/internal/datastream_metadata_decorator.h +++ b/google/cloud/datastream/v1/internal/datastream_metadata_decorator.h @@ -237,6 +237,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..1441d45468e29 100644 --- a/google/cloud/datastream/v1/internal/datastream_stub.cc +++ b/google/cloud/datastream/v1/internal/datastream_stub.cc @@ -536,6 +536,74 @@ 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; +} + +StatusOr +DefaultDatastreamStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultDatastreamStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultDatastreamStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultDatastreamStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..efa22c1c89196 100644 --- a/google/cloud/datastream/v1/internal/datastream_stub.h +++ b/google/cloud/datastream/v1/internal/datastream_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -235,6 +236,31 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -253,9 +279,16 @@ class DefaultDatastreamStub : public DatastreamStub { DefaultDatastreamStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListConnectionProfiles( @@ -455,6 +488,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -470,6 +527,10 @@ class DefaultDatastreamStub : public DatastreamStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..02c622536ce8c 100644 --- a/google/cloud/datastream/v1/internal/datastream_stub_factory.cc +++ b/google/cloud/datastream/v1/internal/datastream_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,14 @@ std::shared_ptr CreateDefaultDatastreamStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::datastream::v1::Datastream::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..3de07d7a72e42 100644 --- a/google/cloud/datastream/v1/internal/datastream_tracing_connection.cc +++ b/google/cloud/datastream/v1/internal/datastream_tracing_connection.cc @@ -488,6 +488,62 @@ 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)); +} + +StreamRange +DatastreamTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("datastream_v1::DatastreamConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DatastreamTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("datastream_v1::DatastreamConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status DatastreamTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "datastream_v1::DatastreamConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status DatastreamTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "datastream_v1::DatastreamConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..054bc788f7c60 100644 --- a/google/cloud/datastream/v1/internal/datastream_tracing_connection.h +++ b/google/cloud/datastream/v1/internal/datastream_tracing_connection.h @@ -228,6 +228,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..5d7746c908faa 100644 --- a/google/cloud/datastream/v1/internal/datastream_tracing_stub.cc +++ b/google/cloud/datastream/v1/internal/datastream_tracing_stub.cc @@ -492,6 +492,74 @@ 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)); +} + +StatusOr +DatastreamTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.datastream.v1.Datastream", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr DatastreamTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.datastream.v1.Datastream", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status DatastreamTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.datastream.v1.Datastream", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status DatastreamTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.datastream.v1.Datastream", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..412ca30db1915 100644 --- a/google/cloud/datastream/v1/internal/datastream_tracing_stub.h +++ b/google/cloud/datastream/v1/internal/datastream_tracing_stub.h @@ -236,6 +236,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..f1565ce064562 100644 --- a/google/cloud/datastream/v1/mocks/mock_datastream_connection.h +++ b/google/cloud/datastream/v1/mocks/mock_datastream_connection.h @@ -533,6 +533,29 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..4d12125b2f401 100644 --- a/google/cloud/deploy/v1/cloud_deploy_client.cc +++ b/google/cloud/deploy/v1/cloud_deploy_client.cc @@ -1073,6 +1073,94 @@ 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); +} + +StreamRange CloudDeployClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange CloudDeployClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr CloudDeployClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr CloudDeployClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status CloudDeployClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status CloudDeployClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status CloudDeployClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status CloudDeployClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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 5d7cc82ce1a80..e3839c435d689 100644 --- a/google/cloud/deploy/v1/cloud_deploy_client.h +++ b/google/cloud/deploy/v1/cloud_deploy_client.h @@ -3396,6 +3396,458 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..51202e59e3d3e 100644 --- a/google/cloud/deploy/v1/cloud_deploy_connection.cc +++ b/google/cloud/deploy/v1/cloud_deploy_connection.cc @@ -520,6 +520,58 @@ 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"); +} + +StreamRange +CloudDeployConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr CloudDeployConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status CloudDeployConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status CloudDeployConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeCloudDeployConnection( Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..a4b9e485d62e9 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,52 @@ 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; +} + +Idempotency CloudDeployConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency CloudDeployConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency CloudDeployConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency CloudDeployConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..f6267ce9f33fe 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,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -155,6 +158,33 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..c4392837e7b14 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,81 @@ 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); +} + +StatusOr +CloudDeployAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr CloudDeployAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status CloudDeployAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status CloudDeployAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..c7f89c62c3faa 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..04ff55be15c2b 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,167 @@ 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__); +} + +StreamRange +CloudDeployConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +CloudDeployConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status CloudDeployConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status CloudDeployConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..71a6c0161a38d 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..6d5dda0ecda62 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,108 @@ 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_); +} + +StatusOr +CloudDeployLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr CloudDeployLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status CloudDeployLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status CloudDeployLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..ee48736c07703 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..b3f5706f1ad28 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,84 @@ 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); +} + +StatusOr +CloudDeployMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr CloudDeployMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status CloudDeployMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status CloudDeployMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..b813250d5c4f3 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..644ceca0d1813 100644 --- a/google/cloud/deploy/v1/internal/cloud_deploy_stub.cc +++ b/google/cloud/deploy/v1/internal/cloud_deploy_stub.cc @@ -765,6 +765,109 @@ 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; +} + +StatusOr +DefaultCloudDeployStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultCloudDeployStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultCloudDeployStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultCloudDeployStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..8bf23169c998a 100644 --- a/google/cloud/deploy/v1/internal/cloud_deploy_stub.h +++ b/google/cloud/deploy/v1/internal/cloud_deploy_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -320,6 +322,44 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -338,9 +378,18 @@ class DefaultCloudDeployStub : public CloudDeployStub { DefaultCloudDeployStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListDeliveryPipelines( @@ -616,6 +665,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -631,6 +716,11 @@ class DefaultCloudDeployStub : public CloudDeployStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..824b5e57c3fee 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,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultCloudDeployStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::deploy::v1::CloudDeploy::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..9470e38ca5a10 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,87 @@ 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)); +} + +StreamRange +CloudDeployTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("deploy_v1::CloudDeployConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +CloudDeployTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("deploy_v1::CloudDeployConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status CloudDeployTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = + internal::MakeSpan("deploy_v1::CloudDeployConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status CloudDeployTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("deploy_v1::CloudDeployConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..26a3d67e73445 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..41794a585c6c8 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,108 @@ 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)); +} + +StatusOr +CloudDeployTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.deploy.v1.CloudDeploy", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr CloudDeployTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.deploy.v1.CloudDeploy", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status CloudDeployTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.deploy.v1.CloudDeploy", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status CloudDeployTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.deploy.v1.CloudDeploy", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..0460d363adeb5 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..1a6eaa986e6d6 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,42 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..d19a403c17278 100644 --- a/google/cloud/developerconnect/v1/developer_connect_client.cc +++ b/google/cloud/developerconnect/v1/developer_connect_client.cc @@ -428,6 +428,79 @@ 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); +} + +StreamRange +DeveloperConnectClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +DeveloperConnectClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr DeveloperConnectClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr DeveloperConnectClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status DeveloperConnectClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status DeveloperConnectClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status DeveloperConnectClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status DeveloperConnectClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..8436616c74917 100644 --- a/google/cloud/developerconnect/v1/developer_connect_client.h +++ b/google/cloud/developerconnect/v1/developer_connect_client.h @@ -1308,6 +1308,356 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..a4f12966cb97e 100644 --- a/google/cloud/developerconnect/v1/developer_connect_connection.cc +++ b/google/cloud/developerconnect/v1/developer_connect_connection.cc @@ -222,6 +222,44 @@ 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"); +} + +StreamRange +DeveloperConnectConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +DeveloperConnectConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DeveloperConnectConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DeveloperConnectConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDeveloperConnectConnection( Options options) { internal::CheckExpectedOptions FetchGitRefs( google::cloud::developerconnect::v1::FetchGitRefsRequest request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..e0ea23b607303 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,36 @@ 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; +} + +Idempotency DeveloperConnectConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DeveloperConnectConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DeveloperConnectConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency DeveloperConnectConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..68e10c6033ed1 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -89,6 +91,24 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..df00c1d14c48f 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,56 @@ 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); +} + +StatusOr +DeveloperConnectAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr DeveloperConnectAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status DeveloperConnectAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status DeveloperConnectAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..92fe56be7a6c7 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..cddcdd41f3e33 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,129 @@ 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__); +} + +StreamRange +DeveloperConnectConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DeveloperConnectConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DeveloperConnectConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DeveloperConnectConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..2db088b92e0dd 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..60f053d62f5d2 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,75 @@ 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_); +} + +StatusOr +DeveloperConnectLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DeveloperConnectLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DeveloperConnectLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DeveloperConnectLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..68e1eb80de600 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..65da034778e0b 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,57 @@ 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); +} + +StatusOr +DeveloperConnectMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr DeveloperConnectMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status DeveloperConnectMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status DeveloperConnectMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..9913f1a757f60 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..a597880ef1189 100644 --- a/google/cloud/developerconnect/v1/internal/developer_connect_stub.cc +++ b/google/cloud/developerconnect/v1/internal/developer_connect_stub.cc @@ -318,6 +318,76 @@ 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; +} + +StatusOr +DefaultDeveloperConnectStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDeveloperConnectStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultDeveloperConnectStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultDeveloperConnectStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..be93d8de0c968 100644 --- a/google/cloud/developerconnect/v1/internal/developer_connect_stub.h +++ b/google/cloud/developerconnect/v1/internal/developer_connect_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -159,6 +160,31 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -178,9 +204,16 @@ class DefaultDeveloperConnectStub : public DeveloperConnectStub { std::unique_ptr< google::cloud::developerconnect::v1::DeveloperConnect::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListConnections( @@ -296,6 +329,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -312,6 +369,10 @@ class DefaultDeveloperConnectStub : public DeveloperConnectStub { std::unique_ptr< google::cloud::developerconnect::v1::DeveloperConnect::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..1eee1fadd74ad 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,14 @@ std::shared_ptr CreateDefaultDeveloperConnectStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::developerconnect::v1::DeveloperConnect::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..6550dd3462d25 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,62 @@ 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)); +} + +StreamRange +DeveloperConnectTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "developerconnect_v1::DeveloperConnectConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DeveloperConnectTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "developerconnect_v1::DeveloperConnectConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status DeveloperConnectTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "developerconnect_v1::DeveloperConnectConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status DeveloperConnectTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "developerconnect_v1::DeveloperConnectConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..6c216f7606eaa 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..37dfe6410c43b 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,76 @@ 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)); +} + +StatusOr +DeveloperConnectTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.developerconnect.v1.DeveloperConnect", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +DeveloperConnectTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.developerconnect.v1.DeveloperConnect", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status DeveloperConnectTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.developerconnect.v1.DeveloperConnect", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status DeveloperConnectTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.developerconnect.v1.DeveloperConnect", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..5f8b7956fd344 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..5ddc7df4844b6 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,29 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..9ae0bafceff64 100644 --- a/google/cloud/dialogflow_cx/agents_client.cc +++ b/google/cloud/dialogflow_cx/agents_client.cc @@ -220,6 +220,60 @@ 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); +} + +StreamRange AgentsClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange AgentsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr AgentsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr AgentsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status AgentsClient::CancelOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status AgentsClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..a724676610716 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..12cdb6f6bdd22 100644 --- a/google/cloud/dialogflow_cx/agents_connection.cc +++ b/google/cloud/dialogflow_cx/agents_connection.cc @@ -131,6 +131,35 @@ 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"); +} + +StreamRange AgentsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr AgentsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AgentsConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeAgentsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..8a5aa18fd52fc 100644 --- a/google/cloud/dialogflow_cx/agents_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_cx/agents_connection_idempotency_policy.cc @@ -89,6 +89,31 @@ 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; +} + +Idempotency AgentsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AgentsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AgentsConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..e1f6482cd48e9 100644 --- a/google/cloud/dialogflow_cx/agents_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_cx/agents_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -71,6 +73,21 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..7199a655e8c43 100644 --- a/google/cloud/dialogflow_cx/changelogs_client.cc +++ b/google/cloud/dialogflow_cx/changelogs_client.cc @@ -64,6 +64,61 @@ 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); +} + +StreamRange ChangelogsClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange ChangelogsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr ChangelogsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr ChangelogsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status ChangelogsClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status ChangelogsClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..f8b460550a562 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..45fb1839e056d 100644 --- a/google/cloud/dialogflow_cx/changelogs_connection.cc +++ b/google/cloud/dialogflow_cx/changelogs_connection.cc @@ -52,6 +52,37 @@ 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"); +} + +StreamRange +ChangelogsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr ChangelogsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ChangelogsConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeChangelogsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..ae1c884f7965a 100644 --- a/google/cloud/dialogflow_cx/changelogs_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_cx/changelogs_connection_idempotency_policy.cc @@ -44,6 +44,31 @@ 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; +} + +Idempotency ChangelogsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ChangelogsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ChangelogsConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..426681eb00136 100644 --- a/google/cloud/dialogflow_cx/changelogs_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_cx/changelogs_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -41,6 +43,21 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..54b1d990be4aa 100644 --- a/google/cloud/dialogflow_cx/deployments_client.cc +++ b/google/cloud/dialogflow_cx/deployments_client.cc @@ -64,6 +64,61 @@ 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); +} + +StreamRange DeploymentsClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange DeploymentsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr DeploymentsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr DeploymentsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status DeploymentsClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status DeploymentsClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..9be91a23910dc 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..f7340735cc3a6 100644 --- a/google/cloud/dialogflow_cx/deployments_connection.cc +++ b/google/cloud/dialogflow_cx/deployments_connection.cc @@ -52,6 +52,37 @@ 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"); +} + +StreamRange +DeploymentsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr DeploymentsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DeploymentsConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDeploymentsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..3370eb0470314 100644 --- a/google/cloud/dialogflow_cx/deployments_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_cx/deployments_connection_idempotency_policy.cc @@ -44,6 +44,31 @@ 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; +} + +Idempotency DeploymentsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DeploymentsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DeploymentsConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..65b7bdd9debde 100644 --- a/google/cloud/dialogflow_cx/deployments_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_cx/deployments_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -41,6 +43,21 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..8a9d0083e70cc 100644 --- a/google/cloud/dialogflow_cx/entity_types_client.cc +++ b/google/cloud/dialogflow_cx/entity_types_client.cc @@ -164,6 +164,61 @@ 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); +} + +StreamRange EntityTypesClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange EntityTypesClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr EntityTypesClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr EntityTypesClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status EntityTypesClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status EntityTypesClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..823bceb59fdfe 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..e35972de0241f 100644 --- a/google/cloud/dialogflow_cx/entity_types_connection.cc +++ b/google/cloud/dialogflow_cx/entity_types_connection.cc @@ -117,6 +117,37 @@ 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"); +} + +StreamRange +EntityTypesConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr EntityTypesConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status EntityTypesConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeEntityTypesConnection( std::string const& location, Options options) { internal::CheckExpectedOptions> ImportEntityTypes(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..962736ce9e46f 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,31 @@ 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; +} + +Idempotency EntityTypesConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency EntityTypesConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency EntityTypesConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..b074f11f7c526 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -61,6 +63,21 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..3eb2ee2870219 100644 --- a/google/cloud/dialogflow_cx/environments_client.cc +++ b/google/cloud/dialogflow_cx/environments_client.cc @@ -250,6 +250,62 @@ 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); +} + +StreamRange EnvironmentsClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange EnvironmentsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr EnvironmentsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr EnvironmentsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status EnvironmentsClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status EnvironmentsClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..6228a512910a3 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..d8e75b0e4295d 100644 --- a/google/cloud/dialogflow_cx/environments_connection.cc +++ b/google/cloud/dialogflow_cx/environments_connection.cc @@ -166,6 +166,37 @@ 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"); +} + +StreamRange +EnvironmentsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr EnvironmentsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status EnvironmentsConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeEnvironmentsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions> DeployFlow(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..4c41a90fbedcd 100644 --- a/google/cloud/dialogflow_cx/environments_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_cx/environments_connection_idempotency_policy.cc @@ -81,6 +81,31 @@ 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; +} + +Idempotency EnvironmentsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency EnvironmentsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency EnvironmentsConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..384e08ace0f51 100644 --- a/google/cloud/dialogflow_cx/environments_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_cx/environments_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -69,6 +71,21 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..14d70679aa3b2 100644 --- a/google/cloud/dialogflow_cx/experiments_client.cc +++ b/google/cloud/dialogflow_cx/experiments_client.cc @@ -150,6 +150,61 @@ 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); +} + +StreamRange ExperimentsClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange ExperimentsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr ExperimentsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr ExperimentsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status ExperimentsClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status ExperimentsClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..184b77991243e 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..3bfb04e42838b 100644 --- a/google/cloud/dialogflow_cx/experiments_connection.cc +++ b/google/cloud/dialogflow_cx/experiments_connection.cc @@ -81,6 +81,37 @@ 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"); +} + +StreamRange +ExperimentsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr ExperimentsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ExperimentsConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeExperimentsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..a1585e09a6ee3 100644 --- a/google/cloud/dialogflow_cx/experiments_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_cx/experiments_connection_idempotency_policy.cc @@ -69,6 +69,31 @@ 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; +} + +Idempotency ExperimentsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ExperimentsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ExperimentsConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..8e8178baa1bbb 100644 --- a/google/cloud/dialogflow_cx/experiments_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_cx/experiments_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 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..3a4980a206959 100644 --- a/google/cloud/dialogflow_cx/flows_client.cc +++ b/google/cloud/dialogflow_cx/flows_client.cc @@ -217,6 +217,60 @@ 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); +} + +StreamRange FlowsClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange FlowsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr FlowsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr FlowsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status FlowsClient::CancelOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status FlowsClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..ac4d6715a7e71 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..b43064092c989 100644 --- a/google/cloud/dialogflow_cx/flows_connection.cc +++ b/google/cloud/dialogflow_cx/flows_connection.cc @@ -137,6 +137,35 @@ 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"); +} + +StreamRange FlowsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr FlowsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status FlowsConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeFlowsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions> ExportFlow(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..d7ca67085c14f 100644 --- a/google/cloud/dialogflow_cx/flows_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_cx/flows_connection_idempotency_policy.cc @@ -83,6 +83,31 @@ 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; +} + +Idempotency FlowsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency FlowsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency FlowsConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..7528205402957 100644 --- a/google/cloud/dialogflow_cx/flows_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_cx/flows_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 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..098da50bbd954 100644 --- a/google/cloud/dialogflow_cx/generators_client.cc +++ b/google/cloud/dialogflow_cx/generators_client.cc @@ -118,6 +118,61 @@ 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); +} + +StreamRange GeneratorsClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange GeneratorsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr GeneratorsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr GeneratorsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status GeneratorsClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status GeneratorsClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..4c9669c502225 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..3998c1069f965 100644 --- a/google/cloud/dialogflow_cx/generators_connection.cc +++ b/google/cloud/dialogflow_cx/generators_connection.cc @@ -69,6 +69,37 @@ 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"); +} + +StreamRange +GeneratorsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr GeneratorsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status GeneratorsConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeGeneratorsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..1a7e626847e8b 100644 --- a/google/cloud/dialogflow_cx/generators_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_cx/generators_connection_idempotency_policy.cc @@ -59,6 +59,31 @@ 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; +} + +Idempotency GeneratorsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency GeneratorsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency GeneratorsConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..86b5206882115 100644 --- a/google/cloud/dialogflow_cx/generators_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_cx/generators_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -50,6 +52,21 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..17790b95775ef 100644 --- a/google/cloud/dialogflow_cx/intents_client.cc +++ b/google/cloud/dialogflow_cx/intents_client.cc @@ -157,6 +157,60 @@ 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); +} + +StreamRange IntentsClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange IntentsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr IntentsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr IntentsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status IntentsClient::CancelOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status IntentsClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..8fd9120e69860 100644 --- a/google/cloud/dialogflow_cx/intents_client.h +++ b/google/cloud/dialogflow_cx/intents_client.h @@ -570,6 +570,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..7ea732da62558 100644 --- a/google/cloud/dialogflow_cx/intents_connection.cc +++ b/google/cloud/dialogflow_cx/intents_connection.cc @@ -113,6 +113,35 @@ 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"); +} + +StreamRange IntentsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr IntentsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status IntentsConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeIntentsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions> ExportIntents(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..922241481d5cb 100644 --- a/google/cloud/dialogflow_cx/intents_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_cx/intents_connection_idempotency_policy.cc @@ -69,6 +69,31 @@ 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; +} + +Idempotency IntentsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency IntentsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency IntentsConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..415a6dac52a97 100644 --- a/google/cloud/dialogflow_cx/intents_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_cx/intents_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 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..dadf71aeb7af7 100644 --- a/google/cloud/dialogflow_cx/internal/agents_auth_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/agents_auth_decorator.cc @@ -165,6 +165,48 @@ 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); +} + +StatusOr +AgentsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr AgentsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status AgentsAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..486fb77262c33 100644 --- a/google/cloud/dialogflow_cx/internal/agents_auth_decorator.h +++ b/google/cloud/dialogflow_cx/internal/agents_auth_decorator.h @@ -111,6 +111,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..dcbd0e8363bdf 100644 --- a/google/cloud/dialogflow_cx/internal/agents_connection_impl.cc +++ b/google/cloud/dialogflow_cx/internal/agents_connection_impl.cc @@ -398,6 +398,112 @@ 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__); +} + +StreamRange +AgentsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr AgentsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status AgentsConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..d6eeb119fb407 100644 --- a/google/cloud/dialogflow_cx/internal/agents_connection_impl.h +++ b/google/cloud/dialogflow_cx/internal/agents_connection_impl.h @@ -113,6 +113,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..e0803efbe9d21 100644 --- a/google/cloud/dialogflow_cx/internal/agents_logging_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/agents_logging_decorator.cc @@ -214,6 +214,63 @@ 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_); +} + +StatusOr +AgentsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AgentsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AgentsLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..fa06b8deb7f36 100644 --- a/google/cloud/dialogflow_cx/internal/agents_logging_decorator.h +++ b/google/cloud/dialogflow_cx/internal/agents_logging_decorator.h @@ -111,6 +111,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..29b158a00a099 100644 --- a/google/cloud/dialogflow_cx/internal/agents_metadata_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/agents_metadata_decorator.cc @@ -167,6 +167,48 @@ 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); +} + +StatusOr +AgentsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr AgentsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status AgentsMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..1149dcab4b146 100644 --- a/google/cloud/dialogflow_cx/internal/agents_metadata_decorator.h +++ b/google/cloud/dialogflow_cx/internal/agents_metadata_decorator.h @@ -111,6 +111,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..dcfb21c760758 100644 --- a/google/cloud/dialogflow_cx/internal/agents_stub.cc +++ b/google/cloud/dialogflow_cx/internal/agents_stub.cc @@ -202,6 +202,63 @@ 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; +} + +StatusOr +DefaultAgentsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAgentsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultAgentsStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..f30fdaea084e0 100644 --- a/google/cloud/dialogflow_cx/internal/agents_stub.h +++ b/google/cloud/dialogflow_cx/internal/agents_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -105,6 +106,27 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -123,9 +145,16 @@ class DefaultAgentsStub : public AgentsStub { DefaultAgentsStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListAgents( grpc::ClientContext& context, Options const& options, @@ -199,6 +228,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -214,6 +263,10 @@ class DefaultAgentsStub : public AgentsStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..96fa43fd7529e 100644 --- a/google/cloud/dialogflow_cx/internal/agents_stub_factory.cc +++ b/google/cloud/dialogflow_cx/internal/agents_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 CreateDefaultAgentsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::cx::v3::Agents::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..cd8fbdd8b22c7 100644 --- a/google/cloud/dialogflow_cx/internal/agents_tracing_connection.cc +++ b/google/cloud/dialogflow_cx/internal/agents_tracing_connection.cc @@ -170,6 +170,53 @@ 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)); +} + +StreamRange +AgentsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_cx::AgentsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr AgentsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::AgentsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status AgentsTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::AgentsConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..2cc05d29086b7 100644 --- a/google/cloud/dialogflow_cx/internal/agents_tracing_connection.h +++ b/google/cloud/dialogflow_cx/internal/agents_tracing_connection.h @@ -101,6 +101,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..32b950043890c 100644 --- a/google/cloud/dialogflow_cx/internal/agents_tracing_stub.cc +++ b/google/cloud/dialogflow_cx/internal/agents_tracing_stub.cc @@ -192,6 +192,63 @@ 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)); +} + +StatusOr +AgentsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Agents", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr AgentsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Agents", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status AgentsTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Agents", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..5ae16ab41577e 100644 --- a/google/cloud/dialogflow_cx/internal/agents_tracing_stub.h +++ b/google/cloud/dialogflow_cx/internal/agents_tracing_stub.h @@ -110,6 +110,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..01be514c6b38c 100644 --- a/google/cloud/dialogflow_cx/internal/changelogs_auth_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/changelogs_auth_decorator.cc @@ -49,6 +49,48 @@ 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); +} + +StatusOr +ChangelogsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr ChangelogsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status ChangelogsAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..7e5af2c0a95fa 100644 --- a/google/cloud/dialogflow_cx/internal/changelogs_auth_decorator.h +++ b/google/cloud/dialogflow_cx/internal/changelogs_auth_decorator.h @@ -48,6 +48,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..e92d5d1191268 100644 --- a/google/cloud/dialogflow_cx/internal/changelogs_connection_impl.cc +++ b/google/cloud/dialogflow_cx/internal/changelogs_connection_impl.cc @@ -109,6 +109,113 @@ 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__); +} + +StreamRange +ChangelogsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr ChangelogsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ChangelogsConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..c59b605178eab 100644 --- a/google/cloud/dialogflow_cx/internal/changelogs_connection_impl.h +++ b/google/cloud/dialogflow_cx/internal/changelogs_connection_impl.h @@ -56,6 +56,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..3ddfccf3d1e89 100644 --- a/google/cloud/dialogflow_cx/internal/changelogs_logging_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/changelogs_logging_decorator.cc @@ -61,6 +61,63 @@ 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_); +} + +StatusOr +ChangelogsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ChangelogsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ChangelogsLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..1b002506f56ba 100644 --- a/google/cloud/dialogflow_cx/internal/changelogs_logging_decorator.h +++ b/google/cloud/dialogflow_cx/internal/changelogs_logging_decorator.h @@ -48,6 +48,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..7629efea8ef85 100644 --- a/google/cloud/dialogflow_cx/internal/changelogs_metadata_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/changelogs_metadata_decorator.cc @@ -62,6 +62,48 @@ 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); +} + +StatusOr +ChangelogsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr ChangelogsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status ChangelogsMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..ef0f1ce9eada0 100644 --- a/google/cloud/dialogflow_cx/internal/changelogs_metadata_decorator.h +++ b/google/cloud/dialogflow_cx/internal/changelogs_metadata_decorator.h @@ -48,6 +48,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..8beab905b3efa 100644 --- a/google/cloud/dialogflow_cx/internal/changelogs_stub.cc +++ b/google/cloud/dialogflow_cx/internal/changelogs_stub.cc @@ -54,6 +54,63 @@ 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; +} + +StatusOr +DefaultChangelogsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultChangelogsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultChangelogsStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..cd58b0dbab3ba 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,27 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultChangelogsStub : public ChangelogsStub { @@ -51,8 +74,14 @@ 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 + operations_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListChangelogs(grpc::ClientContext& context, Options const& options, @@ -64,9 +93,33 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..56232069d55b0 100644 --- a/google/cloud/dialogflow_cx/internal/changelogs_stub_factory.cc +++ b/google/cloud/dialogflow_cx/internal/changelogs_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,14 @@ std::shared_ptr CreateDefaultChangelogsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::cx::v3::Changelogs::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..f30a1142a85a4 100644 --- a/google/cloud/dialogflow_cx/internal/changelogs_tracing_connection.cc +++ b/google/cloud/dialogflow_cx/internal/changelogs_tracing_connection.cc @@ -54,6 +54,54 @@ 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)); +} + +StreamRange +ChangelogsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_cx::ChangelogsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ChangelogsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::ChangelogsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status ChangelogsTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_cx::ChangelogsConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..7af01c4067dce 100644 --- a/google/cloud/dialogflow_cx/internal/changelogs_tracing_connection.h +++ b/google/cloud/dialogflow_cx/internal/changelogs_tracing_connection.h @@ -47,6 +47,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..e731c16051979 100644 --- a/google/cloud/dialogflow_cx/internal/changelogs_tracing_stub.cc +++ b/google/cloud/dialogflow_cx/internal/changelogs_tracing_stub.cc @@ -56,6 +56,63 @@ 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)); +} + +StatusOr +ChangelogsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Changelogs", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr ChangelogsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Changelogs", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status ChangelogsTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Changelogs", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..34eff99a81c9a 100644 --- a/google/cloud/dialogflow_cx/internal/changelogs_tracing_stub.h +++ b/google/cloud/dialogflow_cx/internal/changelogs_tracing_stub.h @@ -48,6 +48,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..18b2832b7d246 100644 --- a/google/cloud/dialogflow_cx/internal/deployments_auth_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/deployments_auth_decorator.cc @@ -49,6 +49,48 @@ 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); +} + +StatusOr +DeploymentsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr DeploymentsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status DeploymentsAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..29eabf3644578 100644 --- a/google/cloud/dialogflow_cx/internal/deployments_auth_decorator.h +++ b/google/cloud/dialogflow_cx/internal/deployments_auth_decorator.h @@ -49,6 +49,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..dda063e2304a1 100644 --- a/google/cloud/dialogflow_cx/internal/deployments_connection_impl.cc +++ b/google/cloud/dialogflow_cx/internal/deployments_connection_impl.cc @@ -109,6 +109,114 @@ 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__); +} + +StreamRange +DeploymentsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DeploymentsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DeploymentsConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..b5c3219dccd9e 100644 --- a/google/cloud/dialogflow_cx/internal/deployments_connection_impl.h +++ b/google/cloud/dialogflow_cx/internal/deployments_connection_impl.h @@ -56,6 +56,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..a336798505c40 100644 --- a/google/cloud/dialogflow_cx/internal/deployments_logging_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/deployments_logging_decorator.cc @@ -61,6 +61,63 @@ 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_); +} + +StatusOr +DeploymentsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DeploymentsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DeploymentsLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..aa27d593cff4b 100644 --- a/google/cloud/dialogflow_cx/internal/deployments_logging_decorator.h +++ b/google/cloud/dialogflow_cx/internal/deployments_logging_decorator.h @@ -49,6 +49,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..5c2fe17f2eef5 100644 --- a/google/cloud/dialogflow_cx/internal/deployments_metadata_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/deployments_metadata_decorator.cc @@ -62,6 +62,48 @@ 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); +} + +StatusOr +DeploymentsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr DeploymentsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status DeploymentsMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..18017116abb59 100644 --- a/google/cloud/dialogflow_cx/internal/deployments_metadata_decorator.h +++ b/google/cloud/dialogflow_cx/internal/deployments_metadata_decorator.h @@ -49,6 +49,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..05b277edd2a3f 100644 --- a/google/cloud/dialogflow_cx/internal/deployments_stub.cc +++ b/google/cloud/dialogflow_cx/internal/deployments_stub.cc @@ -54,6 +54,63 @@ 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; +} + +StatusOr +DefaultDeploymentsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultDeploymentsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultDeploymentsStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..2d6777b56eb0f 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,27 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultDeploymentsStub : public DeploymentsStub { @@ -52,8 +75,14 @@ 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 + operations_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListDeployments( @@ -66,9 +95,33 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..726f44a15a279 100644 --- a/google/cloud/dialogflow_cx/internal/deployments_stub_factory.cc +++ b/google/cloud/dialogflow_cx/internal/deployments_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,14 @@ std::shared_ptr CreateDefaultDeploymentsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::cx::v3::Deployments::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..13cc319073a48 100644 --- a/google/cloud/dialogflow_cx/internal/deployments_tracing_connection.cc +++ b/google/cloud/dialogflow_cx/internal/deployments_tracing_connection.cc @@ -54,6 +54,54 @@ 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)); +} + +StreamRange +DeploymentsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_cx::DeploymentsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DeploymentsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::DeploymentsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status DeploymentsTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_cx::DeploymentsConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..3cf7a578678df 100644 --- a/google/cloud/dialogflow_cx/internal/deployments_tracing_connection.h +++ b/google/cloud/dialogflow_cx/internal/deployments_tracing_connection.h @@ -48,6 +48,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..6d0167f14d928 100644 --- a/google/cloud/dialogflow_cx/internal/deployments_tracing_stub.cc +++ b/google/cloud/dialogflow_cx/internal/deployments_tracing_stub.cc @@ -56,6 +56,63 @@ 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)); +} + +StatusOr +DeploymentsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.Deployments", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr DeploymentsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.Deployments", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status DeploymentsTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.Deployments", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..24e9b53708bad 100644 --- a/google/cloud/dialogflow_cx/internal/deployments_tracing_stub.h +++ b/google/cloud/dialogflow_cx/internal/deployments_tracing_stub.h @@ -49,6 +49,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..a861ee8ca988f 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,48 @@ 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); +} + +StatusOr +EntityTypesAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr EntityTypesAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status EntityTypesAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..a910505f05f61 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..7c640311369e2 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,114 @@ 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__); +} + +StreamRange +EntityTypesConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +EntityTypesConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status EntityTypesConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..abbdab069dd47 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..308b3da57a4a8 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,63 @@ 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_); +} + +StatusOr +EntityTypesLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr EntityTypesLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status EntityTypesLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..0ebea1600ed04 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..305fa1edaa33a 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,48 @@ 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); +} + +StatusOr +EntityTypesMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr EntityTypesMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status EntityTypesMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..7a61f5708f391 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..779f49759aa40 100644 --- a/google/cloud/dialogflow_cx/internal/entity_types_stub.cc +++ b/google/cloud/dialogflow_cx/internal/entity_types_stub.cc @@ -156,6 +156,63 @@ 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; +} + +StatusOr +DefaultEntityTypesStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultEntityTypesStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultEntityTypesStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..276f1c2132806 100644 --- a/google/cloud/dialogflow_cx/internal/entity_types_stub.h +++ b/google/cloud/dialogflow_cx/internal/entity_types_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -92,6 +93,27 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -111,9 +133,16 @@ class DefaultEntityTypesStub : public EntityTypesStub { std::unique_ptr< google::cloud::dialogflow::cx::v3::EntityTypes::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr GetEntityType( grpc::ClientContext& context, Options const& options, @@ -165,6 +194,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -180,6 +229,10 @@ class DefaultEntityTypesStub : public EntityTypesStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..47bee1e6d883c 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,14 @@ std::shared_ptr CreateDefaultEntityTypesStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::cx::v3::EntityTypes::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..2819ff5fb640c 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,54 @@ 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)); +} + +StreamRange +EntityTypesTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_cx::EntityTypesConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +EntityTypesTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::EntityTypesConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status EntityTypesTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_cx::EntityTypesConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..5d06913176635 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..7748fe4a567e6 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,63 @@ 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)); +} + +StatusOr +EntityTypesTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.EntityTypes", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr EntityTypesTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.EntityTypes", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status EntityTypesTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.EntityTypes", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..e3a16393be881 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..ac44b31bc8eb9 100644 --- a/google/cloud/dialogflow_cx/internal/environments_auth_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/environments_auth_decorator.cc @@ -196,6 +196,48 @@ 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); +} + +StatusOr +EnvironmentsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr EnvironmentsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status EnvironmentsAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..57cf489dc6203 100644 --- a/google/cloud/dialogflow_cx/internal/environments_auth_decorator.h +++ b/google/cloud/dialogflow_cx/internal/environments_auth_decorator.h @@ -115,6 +115,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..b558047670ef4 100644 --- a/google/cloud/dialogflow_cx/internal/environments_connection_impl.cc +++ b/google/cloud/dialogflow_cx/internal/environments_connection_impl.cc @@ -580,6 +580,114 @@ 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__); +} + +StreamRange +EnvironmentsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +EnvironmentsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status EnvironmentsConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..a0f501b53e027 100644 --- a/google/cloud/dialogflow_cx/internal/environments_connection_impl.h +++ b/google/cloud/dialogflow_cx/internal/environments_connection_impl.h @@ -125,6 +125,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..d2b62810277c3 100644 --- a/google/cloud/dialogflow_cx/internal/environments_logging_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/environments_logging_decorator.cc @@ -232,6 +232,63 @@ 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_); +} + +StatusOr +EnvironmentsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr EnvironmentsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status EnvironmentsLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..3fb6804fff21e 100644 --- a/google/cloud/dialogflow_cx/internal/environments_logging_decorator.h +++ b/google/cloud/dialogflow_cx/internal/environments_logging_decorator.h @@ -115,6 +115,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..c4e2af0b31768 100644 --- a/google/cloud/dialogflow_cx/internal/environments_metadata_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/environments_metadata_decorator.cc @@ -186,6 +186,48 @@ 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); +} + +StatusOr +EnvironmentsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr EnvironmentsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status EnvironmentsMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..8eb436b84d2dd 100644 --- a/google/cloud/dialogflow_cx/internal/environments_metadata_decorator.h +++ b/google/cloud/dialogflow_cx/internal/environments_metadata_decorator.h @@ -115,6 +115,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..4325131259394 100644 --- a/google/cloud/dialogflow_cx/internal/environments_stub.cc +++ b/google/cloud/dialogflow_cx/internal/environments_stub.cc @@ -224,6 +224,64 @@ 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; +} + +StatusOr +DefaultEnvironmentsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultEnvironmentsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultEnvironmentsStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..2e3037d690204 100644 --- a/google/cloud/dialogflow_cx/internal/environments_stub.h +++ b/google/cloud/dialogflow_cx/internal/environments_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -118,6 +119,27 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -137,9 +159,16 @@ class DefaultEnvironmentsStub : public EnvironmentsStub { std::unique_ptr< google::cloud::dialogflow::cx::v3::Environments::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListEnvironments( @@ -217,6 +246,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -233,6 +282,10 @@ class DefaultEnvironmentsStub : public EnvironmentsStub { std::unique_ptr< google::cloud::dialogflow::cx::v3::Environments::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..c521942d1f2c5 100644 --- a/google/cloud/dialogflow_cx/internal/environments_stub_factory.cc +++ b/google/cloud/dialogflow_cx/internal/environments_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,14 @@ std::shared_ptr CreateDefaultEnvironmentsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::cx::v3::Environments::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..99407f0c60f4b 100644 --- a/google/cloud/dialogflow_cx/internal/environments_tracing_connection.cc +++ b/google/cloud/dialogflow_cx/internal/environments_tracing_connection.cc @@ -213,6 +213,54 @@ 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)); +} + +StreamRange +EnvironmentsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_cx::EnvironmentsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +EnvironmentsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::EnvironmentsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status EnvironmentsTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_cx::EnvironmentsConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..88c66c23ef022 100644 --- a/google/cloud/dialogflow_cx/internal/environments_tracing_connection.h +++ b/google/cloud/dialogflow_cx/internal/environments_tracing_connection.h @@ -113,6 +113,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..3d263a6567f75 100644 --- a/google/cloud/dialogflow_cx/internal/environments_tracing_stub.cc +++ b/google/cloud/dialogflow_cx/internal/environments_tracing_stub.cc @@ -209,6 +209,64 @@ 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)); +} + +StatusOr +EnvironmentsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.Environments", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr EnvironmentsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.Environments", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status EnvironmentsTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.Environments", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..317eacb796ab6 100644 --- a/google/cloud/dialogflow_cx/internal/environments_tracing_stub.h +++ b/google/cloud/dialogflow_cx/internal/environments_tracing_stub.h @@ -114,6 +114,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..6fb163d0aff35 100644 --- a/google/cloud/dialogflow_cx/internal/experiments_auth_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/experiments_auth_decorator.cc @@ -93,6 +93,48 @@ 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); +} + +StatusOr +ExperimentsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr ExperimentsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status ExperimentsAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..1aea7c80f0f4a 100644 --- a/google/cloud/dialogflow_cx/internal/experiments_auth_decorator.h +++ b/google/cloud/dialogflow_cx/internal/experiments_auth_decorator.h @@ -74,6 +74,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..9d977c717d8a3 100644 --- a/google/cloud/dialogflow_cx/internal/experiments_connection_impl.cc +++ b/google/cloud/dialogflow_cx/internal/experiments_connection_impl.cc @@ -183,6 +183,114 @@ 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__); +} + +StreamRange +ExperimentsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ExperimentsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ExperimentsConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..682fbdd970da1 100644 --- a/google/cloud/dialogflow_cx/internal/experiments_connection_impl.h +++ b/google/cloud/dialogflow_cx/internal/experiments_connection_impl.h @@ -76,6 +76,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..a44bd6699461e 100644 --- a/google/cloud/dialogflow_cx/internal/experiments_logging_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/experiments_logging_decorator.cc @@ -125,6 +125,63 @@ 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_); +} + +StatusOr +ExperimentsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ExperimentsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ExperimentsLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..7db6a9a7efdb8 100644 --- a/google/cloud/dialogflow_cx/internal/experiments_logging_decorator.h +++ b/google/cloud/dialogflow_cx/internal/experiments_logging_decorator.h @@ -74,6 +74,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..7369c0a0cedfc 100644 --- a/google/cloud/dialogflow_cx/internal/experiments_metadata_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/experiments_metadata_decorator.cc @@ -107,6 +107,48 @@ 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); +} + +StatusOr +ExperimentsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr ExperimentsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status ExperimentsMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..faac8780fdd36 100644 --- a/google/cloud/dialogflow_cx/internal/experiments_metadata_decorator.h +++ b/google/cloud/dialogflow_cx/internal/experiments_metadata_decorator.h @@ -74,6 +74,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..4be081005316e 100644 --- a/google/cloud/dialogflow_cx/internal/experiments_stub.cc +++ b/google/cloud/dialogflow_cx/internal/experiments_stub.cc @@ -113,6 +113,63 @@ 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; +} + +StatusOr +DefaultExperimentsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultExperimentsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultExperimentsStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..0236cf1e595a9 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,27 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultExperimentsStub : public ExperimentsStub { @@ -80,8 +103,14 @@ 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 + operations_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListExperiments( @@ -119,9 +148,33 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..e400f880f2e7c 100644 --- a/google/cloud/dialogflow_cx/internal/experiments_stub_factory.cc +++ b/google/cloud/dialogflow_cx/internal/experiments_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,14 @@ std::shared_ptr CreateDefaultExperimentsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::cx::v3::Experiments::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..78679007d7662 100644 --- a/google/cloud/dialogflow_cx/internal/experiments_tracing_connection.cc +++ b/google/cloud/dialogflow_cx/internal/experiments_tracing_connection.cc @@ -98,6 +98,54 @@ 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)); +} + +StreamRange +ExperimentsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_cx::ExperimentsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ExperimentsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::ExperimentsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status ExperimentsTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_cx::ExperimentsConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..8e5c7a3d0bdc5 100644 --- a/google/cloud/dialogflow_cx/internal/experiments_tracing_connection.h +++ b/google/cloud/dialogflow_cx/internal/experiments_tracing_connection.h @@ -68,6 +68,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..36b6b78c20751 100644 --- a/google/cloud/dialogflow_cx/internal/experiments_tracing_stub.cc +++ b/google/cloud/dialogflow_cx/internal/experiments_tracing_stub.cc @@ -115,6 +115,63 @@ 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)); +} + +StatusOr +ExperimentsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.Experiments", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr ExperimentsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.Experiments", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status ExperimentsTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.Experiments", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..88ed681e031ca 100644 --- a/google/cloud/dialogflow_cx/internal/experiments_tracing_stub.h +++ b/google/cloud/dialogflow_cx/internal/experiments_tracing_stub.h @@ -74,6 +74,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..5db6e1de4ac53 100644 --- a/google/cloud/dialogflow_cx/internal/flows_auth_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/flows_auth_decorator.cc @@ -172,6 +172,47 @@ 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); +} + +StatusOr FlowsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr FlowsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status FlowsAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..a0d9b334bd820 100644 --- a/google/cloud/dialogflow_cx/internal/flows_auth_decorator.h +++ b/google/cloud/dialogflow_cx/internal/flows_auth_decorator.h @@ -110,6 +110,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..44c62281f0110 100644 --- a/google/cloud/dialogflow_cx/internal/flows_connection_impl.cc +++ b/google/cloud/dialogflow_cx/internal/flows_connection_impl.cc @@ -450,6 +450,111 @@ 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__); +} + +StreamRange FlowsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr FlowsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status FlowsConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..4438302af31e7 100644 --- a/google/cloud/dialogflow_cx/internal/flows_connection_impl.h +++ b/google/cloud/dialogflow_cx/internal/flows_connection_impl.h @@ -113,6 +113,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..074e3a69b5c3b 100644 --- a/google/cloud/dialogflow_cx/internal/flows_logging_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/flows_logging_decorator.cc @@ -212,6 +212,63 @@ 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_); +} + +StatusOr +FlowsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr FlowsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status FlowsLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..ecea7850eb805 100644 --- a/google/cloud/dialogflow_cx/internal/flows_logging_decorator.h +++ b/google/cloud/dialogflow_cx/internal/flows_logging_decorator.h @@ -109,6 +109,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..958064c72847f 100644 --- a/google/cloud/dialogflow_cx/internal/flows_metadata_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/flows_metadata_decorator.cc @@ -162,6 +162,48 @@ 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); +} + +StatusOr +FlowsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr FlowsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status FlowsMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..f152047448ae4 100644 --- a/google/cloud/dialogflow_cx/internal/flows_metadata_decorator.h +++ b/google/cloud/dialogflow_cx/internal/flows_metadata_decorator.h @@ -110,6 +110,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..f31100900dc89 100644 --- a/google/cloud/dialogflow_cx/internal/flows_stub.cc +++ b/google/cloud/dialogflow_cx/internal/flows_stub.cc @@ -202,6 +202,63 @@ 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; +} + +StatusOr +DefaultFlowsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultFlowsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultFlowsStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..7c35dee108fb0 100644 --- a/google/cloud/dialogflow_cx/internal/flows_stub.h +++ b/google/cloud/dialogflow_cx/internal/flows_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -101,6 +102,27 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -119,9 +141,16 @@ class DefaultFlowsStub : public FlowsStub { DefaultFlowsStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr CreateFlow( grpc::ClientContext& context, Options const& options, @@ -194,6 +223,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -209,6 +258,10 @@ class DefaultFlowsStub : public FlowsStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..99c32f5a9154d 100644 --- a/google/cloud/dialogflow_cx/internal/flows_stub_factory.cc +++ b/google/cloud/dialogflow_cx/internal/flows_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 CreateDefaultFlowsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::cx::v3::Flows::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..2ba436177489a 100644 --- a/google/cloud/dialogflow_cx/internal/flows_tracing_connection.cc +++ b/google/cloud/dialogflow_cx/internal/flows_tracing_connection.cc @@ -163,6 +163,51 @@ 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)); +} + +StreamRange +FlowsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_cx::FlowsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr FlowsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::FlowsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status FlowsTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::FlowsConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..3c27aba0eef82 100644 --- a/google/cloud/dialogflow_cx/internal/flows_tracing_connection.h +++ b/google/cloud/dialogflow_cx/internal/flows_tracing_connection.h @@ -102,6 +102,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..a2319941a89b2 100644 --- a/google/cloud/dialogflow_cx/internal/flows_tracing_stub.cc +++ b/google/cloud/dialogflow_cx/internal/flows_tracing_stub.cc @@ -188,6 +188,63 @@ 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)); +} + +StatusOr +FlowsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Flows", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr FlowsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Flows", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status FlowsTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Flows", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..6cb42fa58dc4b 100644 --- a/google/cloud/dialogflow_cx/internal/flows_tracing_stub.h +++ b/google/cloud/dialogflow_cx/internal/flows_tracing_stub.h @@ -109,6 +109,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..bc81446a29aae 100644 --- a/google/cloud/dialogflow_cx/internal/generators_auth_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/generators_auth_decorator.cc @@ -75,6 +75,48 @@ 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); +} + +StatusOr +GeneratorsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr GeneratorsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status GeneratorsAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..e6a8296adde1f 100644 --- a/google/cloud/dialogflow_cx/internal/generators_auth_decorator.h +++ b/google/cloud/dialogflow_cx/internal/generators_auth_decorator.h @@ -63,6 +63,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..5485a728ae02d 100644 --- a/google/cloud/dialogflow_cx/internal/generators_connection_impl.cc +++ b/google/cloud/dialogflow_cx/internal/generators_connection_impl.cc @@ -153,6 +153,113 @@ 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__); +} + +StreamRange +GeneratorsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr GeneratorsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status GeneratorsConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..cc2e943fd96dd 100644 --- a/google/cloud/dialogflow_cx/internal/generators_connection_impl.h +++ b/google/cloud/dialogflow_cx/internal/generators_connection_impl.h @@ -68,6 +68,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..0b1cdbc2eeff6 100644 --- a/google/cloud/dialogflow_cx/internal/generators_logging_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/generators_logging_decorator.cc @@ -99,6 +99,63 @@ 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_); +} + +StatusOr +GeneratorsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr GeneratorsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status GeneratorsLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..e1893da93d88b 100644 --- a/google/cloud/dialogflow_cx/internal/generators_logging_decorator.h +++ b/google/cloud/dialogflow_cx/internal/generators_logging_decorator.h @@ -63,6 +63,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..25240f4f0eb06 100644 --- a/google/cloud/dialogflow_cx/internal/generators_metadata_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/generators_metadata_decorator.cc @@ -89,6 +89,48 @@ 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); +} + +StatusOr +GeneratorsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr GeneratorsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status GeneratorsMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..6393282bf709d 100644 --- a/google/cloud/dialogflow_cx/internal/generators_metadata_decorator.h +++ b/google/cloud/dialogflow_cx/internal/generators_metadata_decorator.h @@ -63,6 +63,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..38fa773d742d2 100644 --- a/google/cloud/dialogflow_cx/internal/generators_stub.cc +++ b/google/cloud/dialogflow_cx/internal/generators_stub.cc @@ -89,6 +89,63 @@ 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; +} + +StatusOr +DefaultGeneratorsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultGeneratorsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultGeneratorsStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..5bd16ec421a1e 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,27 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultGeneratorsStub : public GeneratorsStub { @@ -68,8 +91,14 @@ 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 + operations_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListGenerators(grpc::ClientContext& context, Options const& options, @@ -96,9 +125,33 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..7b6a6c6a8521c 100644 --- a/google/cloud/dialogflow_cx/internal/generators_stub_factory.cc +++ b/google/cloud/dialogflow_cx/internal/generators_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,14 @@ std::shared_ptr CreateDefaultGeneratorsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::cx::v3::Generators::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..6c80a4ba30ca3 100644 --- a/google/cloud/dialogflow_cx/internal/generators_tracing_connection.cc +++ b/google/cloud/dialogflow_cx/internal/generators_tracing_connection.cc @@ -80,6 +80,54 @@ 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)); +} + +StreamRange +GeneratorsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_cx::GeneratorsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +GeneratorsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::GeneratorsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status GeneratorsTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_cx::GeneratorsConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..188b7f8d5cd30 100644 --- a/google/cloud/dialogflow_cx/internal/generators_tracing_connection.h +++ b/google/cloud/dialogflow_cx/internal/generators_tracing_connection.h @@ -59,6 +59,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..ead9f1e37b0f5 100644 --- a/google/cloud/dialogflow_cx/internal/generators_tracing_stub.cc +++ b/google/cloud/dialogflow_cx/internal/generators_tracing_stub.cc @@ -91,6 +91,63 @@ 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)); +} + +StatusOr +GeneratorsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Generators", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr GeneratorsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Generators", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status GeneratorsTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Generators", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..fd82370195351 100644 --- a/google/cloud/dialogflow_cx/internal/generators_tracing_stub.h +++ b/google/cloud/dialogflow_cx/internal/generators_tracing_stub.h @@ -63,6 +63,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..d2e33abc66021 100644 --- a/google/cloud/dialogflow_cx/internal/intents_auth_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/intents_auth_decorator.cc @@ -128,6 +128,48 @@ 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); +} + +StatusOr +IntentsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr IntentsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status IntentsAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..b7363c81baa2d 100644 --- a/google/cloud/dialogflow_cx/internal/intents_auth_decorator.h +++ b/google/cloud/dialogflow_cx/internal/intents_auth_decorator.h @@ -88,6 +88,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..e5657d7e00213 100644 --- a/google/cloud/dialogflow_cx/internal/intents_connection_impl.cc +++ b/google/cloud/dialogflow_cx/internal/intents_connection_impl.cc @@ -341,6 +341,112 @@ 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__); +} + +StreamRange +IntentsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr IntentsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status IntentsConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..58d2cc474994b 100644 --- a/google/cloud/dialogflow_cx/internal/intents_connection_impl.h +++ b/google/cloud/dialogflow_cx/internal/intents_connection_impl.h @@ -94,6 +94,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..11e02e606afb7 100644 --- a/google/cloud/dialogflow_cx/internal/intents_logging_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/intents_logging_decorator.cc @@ -160,6 +160,63 @@ 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_); +} + +StatusOr +IntentsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr IntentsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status IntentsLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..4158494a072bf 100644 --- a/google/cloud/dialogflow_cx/internal/intents_logging_decorator.h +++ b/google/cloud/dialogflow_cx/internal/intents_logging_decorator.h @@ -88,6 +88,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..dc3b6fb2f2a68 100644 --- a/google/cloud/dialogflow_cx/internal/intents_metadata_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/intents_metadata_decorator.cc @@ -128,6 +128,48 @@ 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); +} + +StatusOr +IntentsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr IntentsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status IntentsMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..8b1907c955c0b 100644 --- a/google/cloud/dialogflow_cx/internal/intents_metadata_decorator.h +++ b/google/cloud/dialogflow_cx/internal/intents_metadata_decorator.h @@ -88,6 +88,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..b3829570d08d4 100644 --- a/google/cloud/dialogflow_cx/internal/intents_stub.cc +++ b/google/cloud/dialogflow_cx/internal/intents_stub.cc @@ -150,6 +150,63 @@ 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; +} + +StatusOr +DefaultIntentsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultIntentsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultIntentsStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..64c07df5db5fd 100644 --- a/google/cloud/dialogflow_cx/internal/intents_stub.h +++ b/google/cloud/dialogflow_cx/internal/intents_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -86,6 +87,27 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -104,9 +126,16 @@ class DefaultIntentsStub : public IntentsStub { DefaultIntentsStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListIntents( grpc::ClientContext& context, Options const& options, @@ -157,6 +186,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -172,6 +221,10 @@ class DefaultIntentsStub : public IntentsStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..44561e03ce745 100644 --- a/google/cloud/dialogflow_cx/internal/intents_stub_factory.cc +++ b/google/cloud/dialogflow_cx/internal/intents_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 CreateDefaultIntentsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::cx::v3::Intents::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..8401b6a96cdc2 100644 --- a/google/cloud/dialogflow_cx/internal/intents_tracing_connection.cc +++ b/google/cloud/dialogflow_cx/internal/intents_tracing_connection.cc @@ -135,6 +135,53 @@ 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)); +} + +StreamRange +IntentsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_cx::IntentsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr IntentsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::IntentsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status IntentsTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::IntentsConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..fec29bfa741e3 100644 --- a/google/cloud/dialogflow_cx/internal/intents_tracing_connection.h +++ b/google/cloud/dialogflow_cx/internal/intents_tracing_connection.h @@ -82,6 +82,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..33dc34730dffc 100644 --- a/google/cloud/dialogflow_cx/internal/intents_tracing_stub.cc +++ b/google/cloud/dialogflow_cx/internal/intents_tracing_stub.cc @@ -140,6 +140,63 @@ 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)); +} + +StatusOr +IntentsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Intents", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr IntentsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Intents", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status IntentsTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Intents", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..81a6c743a755c 100644 --- a/google/cloud/dialogflow_cx/internal/intents_tracing_stub.h +++ b/google/cloud/dialogflow_cx/internal/intents_tracing_stub.h @@ -87,6 +87,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..8f85473a90b5e 100644 --- a/google/cloud/dialogflow_cx/internal/pages_auth_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/pages_auth_decorator.cc @@ -72,6 +72,47 @@ 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); +} + +StatusOr PagesAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr PagesAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status PagesAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..6d20463aa0006 100644 --- a/google/cloud/dialogflow_cx/internal/pages_auth_decorator.h +++ b/google/cloud/dialogflow_cx/internal/pages_auth_decorator.h @@ -62,6 +62,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..6d02aadc4e9ee 100644 --- a/google/cloud/dialogflow_cx/internal/pages_connection_impl.cc +++ b/google/cloud/dialogflow_cx/internal/pages_connection_impl.cc @@ -148,6 +148,111 @@ 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__); +} + +StreamRange PagesConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr PagesConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status PagesConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..0b2b8ae245df9 100644 --- a/google/cloud/dialogflow_cx/internal/pages_connection_impl.h +++ b/google/cloud/dialogflow_cx/internal/pages_connection_impl.h @@ -65,6 +65,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..f83e7a3b425a2 100644 --- a/google/cloud/dialogflow_cx/internal/pages_logging_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/pages_logging_decorator.cc @@ -95,6 +95,63 @@ 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_); +} + +StatusOr +PagesLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr PagesLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status PagesLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..63d3ca8b6eec5 100644 --- a/google/cloud/dialogflow_cx/internal/pages_logging_decorator.h +++ b/google/cloud/dialogflow_cx/internal/pages_logging_decorator.h @@ -61,6 +61,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..d13c67f371459 100644 --- a/google/cloud/dialogflow_cx/internal/pages_metadata_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/pages_metadata_decorator.cc @@ -86,6 +86,48 @@ 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); +} + +StatusOr +PagesMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr PagesMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status PagesMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..e071f45e876d1 100644 --- a/google/cloud/dialogflow_cx/internal/pages_metadata_decorator.h +++ b/google/cloud/dialogflow_cx/internal/pages_metadata_decorator.h @@ -62,6 +62,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..9712b36720241 100644 --- a/google/cloud/dialogflow_cx/internal/pages_stub.cc +++ b/google/cloud/dialogflow_cx/internal/pages_stub.cc @@ -86,6 +86,63 @@ 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; +} + +StatusOr +DefaultPagesStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultPagesStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultPagesStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..55da130c4c8f7 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,41 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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 + operations_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListPages( grpc::ClientContext& context, Options const& options, @@ -88,9 +117,33 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..b2b4442bcd1d3 100644 --- a/google/cloud/dialogflow_cx/internal/pages_stub_factory.cc +++ b/google/cloud/dialogflow_cx/internal/pages_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 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_operations_stub = + google::longrunning::Operations::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_operations_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..53ca82aac59cb 100644 --- a/google/cloud/dialogflow_cx/internal/pages_tracing_connection.cc +++ b/google/cloud/dialogflow_cx/internal/pages_tracing_connection.cc @@ -74,6 +74,51 @@ 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)); +} + +StreamRange +PagesTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_cx::PagesConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr PagesTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::PagesConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status PagesTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::PagesConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..4992da370f381 100644 --- a/google/cloud/dialogflow_cx/internal/pages_tracing_connection.h +++ b/google/cloud/dialogflow_cx/internal/pages_tracing_connection.h @@ -57,6 +57,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..414a9dac21184 100644 --- a/google/cloud/dialogflow_cx/internal/pages_tracing_stub.cc +++ b/google/cloud/dialogflow_cx/internal/pages_tracing_stub.cc @@ -87,6 +87,63 @@ 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)); +} + +StatusOr +PagesTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Pages", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr PagesTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Pages", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status PagesTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Pages", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..70dfc762c0318 100644 --- a/google/cloud/dialogflow_cx/internal/pages_tracing_stub.h +++ b/google/cloud/dialogflow_cx/internal/pages_tracing_stub.h @@ -62,6 +62,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..2c2aaf0d53b73 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,50 @@ 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); +} + +StatusOr +SecuritySettingsServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +SecuritySettingsServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status SecuritySettingsServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..6fd8730dca1be 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..3ab57379b3d86 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,116 @@ 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__); +} + +StreamRange +SecuritySettingsServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +SecuritySettingsServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status SecuritySettingsServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..72a9452f167a5 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..7aa5e99c754f5 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,65 @@ 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_); +} + +StatusOr +SecuritySettingsServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +SecuritySettingsServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status SecuritySettingsServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..27aa40064688e 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..5ea146c4ce05b 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,50 @@ 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); +} + +StatusOr +SecuritySettingsServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +SecuritySettingsServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status SecuritySettingsServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..4bb894c9d4cb1 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..9a95efdd234a4 100644 --- a/google/cloud/dialogflow_cx/internal/security_settings_stub.cc +++ b/google/cloud/dialogflow_cx/internal/security_settings_stub.cc @@ -97,6 +97,65 @@ 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; +} + +StatusOr +DefaultSecuritySettingsServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultSecuritySettingsServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultSecuritySettingsServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..5d2d0390e3d4e 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,27 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultSecuritySettingsServiceStub : public SecuritySettingsServiceStub { @@ -71,8 +94,14 @@ class DefaultSecuritySettingsServiceStub : public SecuritySettingsServiceStub { explicit DefaultSecuritySettingsServiceStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr CreateSecuritySettings( @@ -103,10 +132,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr< google::cloud::dialogflow::cx::v3::SecuritySettingsService::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..638e04b548de0 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -46,9 +48,14 @@ CreateDefaultSecuritySettingsServiceStub( auto service_grpc_stub = google::cloud::dialogflow::cx::v3::SecuritySettingsService::NewStub( channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..fb11953ba28bb 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,54 @@ 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)); +} + +StreamRange +SecuritySettingsServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_cx::SecuritySettingsServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +SecuritySettingsServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_cx::SecuritySettingsServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status SecuritySettingsServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_cx::SecuritySettingsServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..ba1db15830778 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..5db71ed18a828 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,67 @@ 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)); +} + +StatusOr +SecuritySettingsServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.SecuritySettingsService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +SecuritySettingsServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.SecuritySettingsService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status SecuritySettingsServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.SecuritySettingsService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..b61970d9abb71 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..300e67bcb0a0e 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,48 @@ 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); +} + +StatusOr +SessionEntityTypesAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr SessionEntityTypesAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status SessionEntityTypesAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..035eb3d8c9b4f 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..fddc477472b0a 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,114 @@ 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__); +} + +StreamRange +SessionEntityTypesConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +SessionEntityTypesConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status SessionEntityTypesConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..06bef65b892d2 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..6d6fb9908a2fc 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,65 @@ 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_); +} + +StatusOr +SessionEntityTypesLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +SessionEntityTypesLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status SessionEntityTypesLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..d12b7963c606e 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..082fe6d4d80e1 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,50 @@ 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); +} + +StatusOr +SessionEntityTypesMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +SessionEntityTypesMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status SessionEntityTypesMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..26522eb897403 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..f821d91b480cd 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,65 @@ 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; +} + +StatusOr +DefaultSessionEntityTypesStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultSessionEntityTypesStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultSessionEntityTypesStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..d64d3b5ab40eb 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,27 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultSessionEntityTypesStub : public SessionEntityTypesStub { @@ -71,8 +94,14 @@ 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 + operations_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListSessionEntityTypes( @@ -103,10 +132,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr< google::cloud::dialogflow::cx::v3::SessionEntityTypes::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..81e91f05f3a4a 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,14 @@ std::shared_ptr CreateDefaultSessionEntityTypesStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::cx::v3::SessionEntityTypes::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..b455a0009aa2e 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,54 @@ 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)); +} + +StreamRange +SessionEntityTypesTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_cx::SessionEntityTypesConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +SessionEntityTypesTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_cx::SessionEntityTypesConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status SessionEntityTypesTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_cx::SessionEntityTypesConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..7299ae45339f1 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..95f2650e485e7 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,65 @@ 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)); +} + +StatusOr +SessionEntityTypesTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.SessionEntityTypes", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +SessionEntityTypesTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.SessionEntityTypes", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status SessionEntityTypesTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.SessionEntityTypes", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..103e2ae0b4bbd 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..e5d9c8b1dbdb0 100644 --- a/google/cloud/dialogflow_cx/internal/sessions_auth_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/sessions_auth_decorator.cc @@ -101,6 +101,48 @@ 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); +} + +StatusOr +SessionsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr SessionsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status SessionsAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..14ed21263a431 100644 --- a/google/cloud/dialogflow_cx/internal/sessions_auth_decorator.h +++ b/google/cloud/dialogflow_cx/internal/sessions_auth_decorator.h @@ -74,6 +74,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..6aab64ba3577e 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,112 @@ 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__); +} + +StreamRange +SessionsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr SessionsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status SessionsConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..5f3a1582ba5fa 100644 --- a/google/cloud/dialogflow_cx/internal/sessions_connection_impl.h +++ b/google/cloud/dialogflow_cx/internal/sessions_connection_impl.h @@ -80,6 +80,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..7e2bf47261b8e 100644 --- a/google/cloud/dialogflow_cx/internal/sessions_logging_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/sessions_logging_decorator.cc @@ -141,6 +141,63 @@ 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_); +} + +StatusOr +SessionsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr SessionsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status SessionsLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..2f87fba252897 100644 --- a/google/cloud/dialogflow_cx/internal/sessions_logging_decorator.h +++ b/google/cloud/dialogflow_cx/internal/sessions_logging_decorator.h @@ -74,6 +74,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..e374054aa9478 100644 --- a/google/cloud/dialogflow_cx/internal/sessions_metadata_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/sessions_metadata_decorator.cc @@ -106,6 +106,48 @@ 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); +} + +StatusOr +SessionsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr SessionsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status SessionsMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..2f54604fecce1 100644 --- a/google/cloud/dialogflow_cx/internal/sessions_metadata_decorator.h +++ b/google/cloud/dialogflow_cx/internal/sessions_metadata_decorator.h @@ -74,6 +74,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..af2c81bb4e383 100644 --- a/google/cloud/dialogflow_cx/internal/sessions_stub.cc +++ b/google/cloud/dialogflow_cx/internal/sessions_stub.cc @@ -107,6 +107,63 @@ 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; +} + +StatusOr +DefaultSessionsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultSessionsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultSessionsStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..d83fcdc30edbd 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,27 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultSessionsStub : public SessionsStub { @@ -80,8 +103,14 @@ 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 + operations_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr DetectIntent(grpc::ClientContext& context, Options const& options, @@ -119,9 +148,33 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..2d66f32a3a41f 100644 --- a/google/cloud/dialogflow_cx/internal/sessions_stub_factory.cc +++ b/google/cloud/dialogflow_cx/internal/sessions_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 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_operations_stub = + google::longrunning::Operations::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_operations_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..f09aba810d24b 100644 --- a/google/cloud/dialogflow_cx/internal/sessions_tracing_connection.cc +++ b/google/cloud/dialogflow_cx/internal/sessions_tracing_connection.cc @@ -88,6 +88,54 @@ 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)); +} + +StreamRange +SessionsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_cx::SessionsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +SessionsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::SessionsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status SessionsTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::SessionsConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..e8b81e6e4d877 100644 --- a/google/cloud/dialogflow_cx/internal/sessions_tracing_connection.h +++ b/google/cloud/dialogflow_cx/internal/sessions_tracing_connection.h @@ -66,6 +66,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..0b77cc2e8f0fe 100644 --- a/google/cloud/dialogflow_cx/internal/sessions_tracing_stub.cc +++ b/google/cloud/dialogflow_cx/internal/sessions_tracing_stub.cc @@ -115,6 +115,63 @@ 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)); +} + +StatusOr +SessionsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Sessions", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr SessionsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Sessions", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status SessionsTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Sessions", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..9df8634c2176d 100644 --- a/google/cloud/dialogflow_cx/internal/sessions_tracing_stub.h +++ b/google/cloud/dialogflow_cx/internal/sessions_tracing_stub.h @@ -74,6 +74,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..1f9981010aec7 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,48 @@ 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); +} + +StatusOr +TestCasesAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr TestCasesAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status TestCasesAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..d5216f19f5720 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..831eaaacf1fc4 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,113 @@ 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__); +} + +StreamRange +TestCasesConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr TestCasesConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status TestCasesConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..32661cc36ecd5 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..f103d19b0630a 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,63 @@ 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_); +} + +StatusOr +TestCasesLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr TestCasesLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status TestCasesLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..883be0ff23d0f 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..57578122bdd87 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,48 @@ 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); +} + +StatusOr +TestCasesMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr TestCasesMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status TestCasesMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..8ed1ba64d7c96 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..2ac722c31563c 100644 --- a/google/cloud/dialogflow_cx/internal/test_cases_stub.cc +++ b/google/cloud/dialogflow_cx/internal/test_cases_stub.cc @@ -253,6 +253,63 @@ 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; +} + +StatusOr +DefaultTestCasesStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultTestCasesStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultTestCasesStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..de4374c7d0e32 100644 --- a/google/cloud/dialogflow_cx/internal/test_cases_stub.h +++ b/google/cloud/dialogflow_cx/internal/test_cases_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -128,6 +129,27 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -147,9 +169,16 @@ class DefaultTestCasesStub : public TestCasesStub { std::unique_ptr< google::cloud::dialogflow::cx::v3::TestCases::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListTestCases(grpc::ClientContext& context, Options const& options, @@ -241,6 +270,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -256,6 +305,10 @@ class DefaultTestCasesStub : public TestCasesStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..72f81cfa2bb91 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,8 +46,13 @@ std::shared_ptr CreateDefaultTestCasesStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::cx::v3::TestCases::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..a9ed9c69fee3a 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,54 @@ 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)); +} + +StreamRange +TestCasesTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_cx::TestCasesConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +TestCasesTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::TestCasesConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status TestCasesTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::TestCasesConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..2568d3ab2fb01 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..2393b4bdad6e8 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,63 @@ 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)); +} + +StatusOr +TestCasesTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.TestCases", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr TestCasesTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.TestCases", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status TestCasesTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.TestCases", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..d6a12429b5af4 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..7f585279ab85c 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,50 @@ 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); +} + +StatusOr +TransitionRouteGroupsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +TransitionRouteGroupsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status TransitionRouteGroupsAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..3f895483e22f6 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..9d45ef3b9eed7 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,114 @@ 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__); +} + +StreamRange +TransitionRouteGroupsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +TransitionRouteGroupsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status TransitionRouteGroupsConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..7da325d65c9e8 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..6280787768d5b 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,65 @@ 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_); +} + +StatusOr +TransitionRouteGroupsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +TransitionRouteGroupsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status TransitionRouteGroupsLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..6750dd2221478 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..efcd5c33634a6 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,50 @@ 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); +} + +StatusOr +TransitionRouteGroupsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +TransitionRouteGroupsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status TransitionRouteGroupsMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..d0d3bc69a6bd5 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..3339652de96b5 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,65 @@ 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; +} + +StatusOr +DefaultTransitionRouteGroupsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultTransitionRouteGroupsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultTransitionRouteGroupsStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..f9ec1278c2c1d 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,27 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultTransitionRouteGroupsStub : public TransitionRouteGroupsStub { @@ -71,8 +94,14 @@ class DefaultTransitionRouteGroupsStub : public TransitionRouteGroupsStub { explicit DefaultTransitionRouteGroupsStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListTransitionRouteGroups( @@ -103,10 +132,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr< google::cloud::dialogflow::cx::v3::TransitionRouteGroups::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..62e3e5e34e814 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -46,9 +48,14 @@ CreateDefaultTransitionRouteGroupsStub( auto service_grpc_stub = google::cloud::dialogflow::cx::v3::TransitionRouteGroups::NewStub( channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..cff83eaba9f6c 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,54 @@ 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)); +} + +StreamRange +TransitionRouteGroupsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_cx::TransitionRouteGroupsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +TransitionRouteGroupsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_cx::TransitionRouteGroupsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status TransitionRouteGroupsTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_cx::TransitionRouteGroupsConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..07bc2a4b3036e 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..d4b31dc216e2c 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,65 @@ 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)); +} + +StatusOr +TransitionRouteGroupsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.TransitionRouteGroups", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +TransitionRouteGroupsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.TransitionRouteGroups", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status TransitionRouteGroupsTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.TransitionRouteGroups", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..14d9fe781cb9d 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..8d0a07a2b3f4b 100644 --- a/google/cloud/dialogflow_cx/internal/versions_auth_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/versions_auth_decorator.cc @@ -129,6 +129,48 @@ 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); +} + +StatusOr +VersionsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr VersionsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status VersionsAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..2bda16edea3cb 100644 --- a/google/cloud/dialogflow_cx/internal/versions_auth_decorator.h +++ b/google/cloud/dialogflow_cx/internal/versions_auth_decorator.h @@ -89,6 +89,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..e290a6978cecb 100644 --- a/google/cloud/dialogflow_cx/internal/versions_connection_impl.cc +++ b/google/cloud/dialogflow_cx/internal/versions_connection_impl.cc @@ -337,6 +337,112 @@ 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__); +} + +StreamRange +VersionsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr VersionsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status VersionsConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..776fe5ba812bd 100644 --- a/google/cloud/dialogflow_cx/internal/versions_connection_impl.h +++ b/google/cloud/dialogflow_cx/internal/versions_connection_impl.h @@ -95,6 +95,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..2e22558caa989 100644 --- a/google/cloud/dialogflow_cx/internal/versions_logging_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/versions_logging_decorator.cc @@ -161,6 +161,63 @@ 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_); +} + +StatusOr +VersionsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr VersionsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status VersionsLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..167ef0917c36a 100644 --- a/google/cloud/dialogflow_cx/internal/versions_logging_decorator.h +++ b/google/cloud/dialogflow_cx/internal/versions_logging_decorator.h @@ -89,6 +89,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..955105677eb06 100644 --- a/google/cloud/dialogflow_cx/internal/versions_metadata_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/versions_metadata_decorator.cc @@ -130,6 +130,48 @@ 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); +} + +StatusOr +VersionsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr VersionsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status VersionsMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..338a8579588a7 100644 --- a/google/cloud/dialogflow_cx/internal/versions_metadata_decorator.h +++ b/google/cloud/dialogflow_cx/internal/versions_metadata_decorator.h @@ -89,6 +89,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..5552bd8351821 100644 --- a/google/cloud/dialogflow_cx/internal/versions_stub.cc +++ b/google/cloud/dialogflow_cx/internal/versions_stub.cc @@ -150,6 +150,63 @@ 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; +} + +StatusOr +DefaultVersionsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultVersionsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultVersionsStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..ea1fdd87b6304 100644 --- a/google/cloud/dialogflow_cx/internal/versions_stub.h +++ b/google/cloud/dialogflow_cx/internal/versions_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -86,6 +87,27 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -105,9 +127,16 @@ class DefaultVersionsStub : public VersionsStub { std::unique_ptr< google::cloud::dialogflow::cx::v3::Versions::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListVersions(grpc::ClientContext& context, Options const& options, @@ -159,6 +188,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -174,6 +223,10 @@ class DefaultVersionsStub : public VersionsStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..cd90f02eeab24 100644 --- a/google/cloud/dialogflow_cx/internal/versions_stub_factory.cc +++ b/google/cloud/dialogflow_cx/internal/versions_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 CreateDefaultVersionsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::cx::v3::Versions::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..882cd39d84753 100644 --- a/google/cloud/dialogflow_cx/internal/versions_tracing_connection.cc +++ b/google/cloud/dialogflow_cx/internal/versions_tracing_connection.cc @@ -135,6 +135,54 @@ 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)); +} + +StreamRange +VersionsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_cx::VersionsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +VersionsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::VersionsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status VersionsTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::VersionsConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..691ca1ab1a87e 100644 --- a/google/cloud/dialogflow_cx/internal/versions_tracing_connection.h +++ b/google/cloud/dialogflow_cx/internal/versions_tracing_connection.h @@ -83,6 +83,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..425fa673543ff 100644 --- a/google/cloud/dialogflow_cx/internal/versions_tracing_stub.cc +++ b/google/cloud/dialogflow_cx/internal/versions_tracing_stub.cc @@ -140,6 +140,63 @@ 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)); +} + +StatusOr +VersionsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Versions", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr VersionsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Versions", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status VersionsTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Versions", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..e03112a2207ba 100644 --- a/google/cloud/dialogflow_cx/internal/versions_tracing_stub.h +++ b/google/cloud/dialogflow_cx/internal/versions_tracing_stub.h @@ -88,6 +88,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..9272dbd8ed069 100644 --- a/google/cloud/dialogflow_cx/internal/webhooks_auth_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/webhooks_auth_decorator.cc @@ -74,6 +74,48 @@ 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); +} + +StatusOr +WebhooksAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr WebhooksAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status WebhooksAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..3690d2ac9c546 100644 --- a/google/cloud/dialogflow_cx/internal/webhooks_auth_decorator.h +++ b/google/cloud/dialogflow_cx/internal/webhooks_auth_decorator.h @@ -63,6 +63,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..e108c8c5b1853 100644 --- a/google/cloud/dialogflow_cx/internal/webhooks_connection_impl.cc +++ b/google/cloud/dialogflow_cx/internal/webhooks_connection_impl.cc @@ -151,6 +151,112 @@ 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__); +} + +StreamRange +WebhooksConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr WebhooksConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status WebhooksConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..aee8d25147710 100644 --- a/google/cloud/dialogflow_cx/internal/webhooks_connection_impl.h +++ b/google/cloud/dialogflow_cx/internal/webhooks_connection_impl.h @@ -67,6 +67,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..8f2c07d392975 100644 --- a/google/cloud/dialogflow_cx/internal/webhooks_logging_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/webhooks_logging_decorator.cc @@ -99,6 +99,63 @@ 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_); +} + +StatusOr +WebhooksLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr WebhooksLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status WebhooksLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..cbd0f5f40a30c 100644 --- a/google/cloud/dialogflow_cx/internal/webhooks_logging_decorator.h +++ b/google/cloud/dialogflow_cx/internal/webhooks_logging_decorator.h @@ -63,6 +63,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..d8495d3445acb 100644 --- a/google/cloud/dialogflow_cx/internal/webhooks_metadata_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/webhooks_metadata_decorator.cc @@ -89,6 +89,48 @@ 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); +} + +StatusOr +WebhooksMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr WebhooksMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status WebhooksMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..f0d96236c9f93 100644 --- a/google/cloud/dialogflow_cx/internal/webhooks_metadata_decorator.h +++ b/google/cloud/dialogflow_cx/internal/webhooks_metadata_decorator.h @@ -63,6 +63,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..ce4efa306c110 100644 --- a/google/cloud/dialogflow_cx/internal/webhooks_stub.cc +++ b/google/cloud/dialogflow_cx/internal/webhooks_stub.cc @@ -89,6 +89,63 @@ 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; +} + +StatusOr +DefaultWebhooksStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultWebhooksStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultWebhooksStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..54669df1256e5 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,27 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultWebhooksStub : public WebhooksStub { @@ -65,8 +88,14 @@ 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 + operations_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListWebhooks(grpc::ClientContext& context, Options const& options, @@ -93,9 +122,33 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..aa6627b1aff05 100644 --- a/google/cloud/dialogflow_cx/internal/webhooks_stub_factory.cc +++ b/google/cloud/dialogflow_cx/internal/webhooks_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 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_operations_stub = + google::longrunning::Operations::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_operations_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..078b02d68cb93 100644 --- a/google/cloud/dialogflow_cx/internal/webhooks_tracing_connection.cc +++ b/google/cloud/dialogflow_cx/internal/webhooks_tracing_connection.cc @@ -80,6 +80,54 @@ 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)); +} + +StreamRange +WebhooksTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_cx::WebhooksConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +WebhooksTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::WebhooksConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status WebhooksTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::WebhooksConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..c2c3e6851bed1 100644 --- a/google/cloud/dialogflow_cx/internal/webhooks_tracing_connection.h +++ b/google/cloud/dialogflow_cx/internal/webhooks_tracing_connection.h @@ -58,6 +58,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..f1a64d8b68bfb 100644 --- a/google/cloud/dialogflow_cx/internal/webhooks_tracing_stub.cc +++ b/google/cloud/dialogflow_cx/internal/webhooks_tracing_stub.cc @@ -90,6 +90,63 @@ 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)); +} + +StatusOr +WebhooksTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Webhooks", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr WebhooksTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Webhooks", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status WebhooksTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Webhooks", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..6a31da520bfcb 100644 --- a/google/cloud/dialogflow_cx/internal/webhooks_tracing_stub.h +++ b/google/cloud/dialogflow_cx/internal/webhooks_tracing_stub.h @@ -63,6 +63,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..423ee78e30e6a 100644 --- a/google/cloud/dialogflow_cx/mocks/mock_agents_connection.h +++ b/google/cloud/dialogflow_cx/mocks/mock_agents_connection.h @@ -174,6 +174,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..66bd509d9a05b 100644 --- a/google/cloud/dialogflow_cx/mocks/mock_changelogs_connection.h +++ b/google/cloud/dialogflow_cx/mocks/mock_changelogs_connection.h @@ -56,6 +56,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..d0687e297412b 100644 --- a/google/cloud/dialogflow_cx/mocks/mock_deployments_connection.h +++ b/google/cloud/dialogflow_cx/mocks/mock_deployments_connection.h @@ -56,6 +56,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..61b2162e6d7e0 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,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..9d62b98641577 100644 --- a/google/cloud/dialogflow_cx/mocks/mock_environments_connection.h +++ b/google/cloud/dialogflow_cx/mocks/mock_environments_connection.h @@ -243,6 +243,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..814166e24384f 100644 --- a/google/cloud/dialogflow_cx/mocks/mock_experiments_connection.h +++ b/google/cloud/dialogflow_cx/mocks/mock_experiments_connection.h @@ -84,6 +84,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..68ddf89767447 100644 --- a/google/cloud/dialogflow_cx/mocks/mock_flows_connection.h +++ b/google/cloud/dialogflow_cx/mocks/mock_flows_connection.h @@ -199,6 +199,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..691a7f3da1e9e 100644 --- a/google/cloud/dialogflow_cx/mocks/mock_generators_connection.h +++ b/google/cloud/dialogflow_cx/mocks/mock_generators_connection.h @@ -73,6 +73,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..17cacd0ff5f84 100644 --- a/google/cloud/dialogflow_cx/mocks/mock_intents_connection.h +++ b/google/cloud/dialogflow_cx/mocks/mock_intents_connection.h @@ -154,6 +154,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..fa322eb067426 100644 --- a/google/cloud/dialogflow_cx/mocks/mock_pages_connection.h +++ b/google/cloud/dialogflow_cx/mocks/mock_pages_connection.h @@ -69,6 +69,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..6ddb08ea64f53 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,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..cd86fa04c6057 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,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..d80316b2c95ee 100644 --- a/google/cloud/dialogflow_cx/mocks/mock_sessions_connection.h +++ b/google/cloud/dialogflow_cx/mocks/mock_sessions_connection.h @@ -82,6 +82,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..5a93968a35ca3 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,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..600956b90ccb9 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,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..5dd66ad111fcc 100644 --- a/google/cloud/dialogflow_cx/mocks/mock_versions_connection.h +++ b/google/cloud/dialogflow_cx/mocks/mock_versions_connection.h @@ -148,6 +148,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..fcba103e497a4 100644 --- a/google/cloud/dialogflow_cx/mocks/mock_webhooks_connection.h +++ b/google/cloud/dialogflow_cx/mocks/mock_webhooks_connection.h @@ -70,6 +70,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..13b6d7a9891d2 100644 --- a/google/cloud/dialogflow_cx/pages_client.cc +++ b/google/cloud/dialogflow_cx/pages_client.cc @@ -109,6 +109,60 @@ 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); +} + +StreamRange PagesClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange PagesClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr PagesClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr PagesClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status PagesClient::CancelOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status PagesClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..73cff4d93fc8b 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..775dc92999827 100644 --- a/google/cloud/dialogflow_cx/pages_connection.cc +++ b/google/cloud/dialogflow_cx/pages_connection.cc @@ -65,6 +65,35 @@ 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"); +} + +StreamRange PagesConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr PagesConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status PagesConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakePagesConnection( std::string const& location, Options options) { internal::CheckExpectedOptions ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..72f757062f749 100644 --- a/google/cloud/dialogflow_cx/pages_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_cx/pages_connection_idempotency_policy.cc @@ -58,6 +58,31 @@ 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; +} + +Idempotency PagesConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency PagesConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency PagesConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..54133958ec11c 100644 --- a/google/cloud/dialogflow_cx/pages_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_cx/pages_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -50,6 +52,21 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..7fb2f269573b8 100644 --- a/google/cloud/dialogflow_cx/security_settings_client.cc +++ b/google/cloud/dialogflow_cx/security_settings_client.cc @@ -126,6 +126,68 @@ 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); +} + +StreamRange +SecuritySettingsServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +SecuritySettingsServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +SecuritySettingsServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +SecuritySettingsServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status SecuritySettingsServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status SecuritySettingsServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..4c91d4c39ec24 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..d2cef9ebf2802 100644 --- a/google/cloud/dialogflow_cx/security_settings_connection.cc +++ b/google/cloud/dialogflow_cx/security_settings_connection.cc @@ -70,6 +70,39 @@ 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"); +} + +StreamRange +SecuritySettingsServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +SecuritySettingsServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status SecuritySettingsServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest 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..1db1e120e3f61 100644 --- a/google/cloud/dialogflow_cx/security_settings_connection.h +++ b/google/cloud/dialogflow_cx/security_settings_connection.h @@ -213,6 +213,21 @@ 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..3cd88f558f723 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,31 @@ 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; +} + +Idempotency SecuritySettingsServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SecuritySettingsServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency SecuritySettingsServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..8625fd8c1f072 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -55,6 +57,21 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..b3a0f71e25b86 100644 --- a/google/cloud/dialogflow_cx/session_entity_types_client.cc +++ b/google/cloud/dialogflow_cx/session_entity_types_client.cc @@ -126,6 +126,66 @@ 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); +} + +StreamRange +SessionEntityTypesClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +SessionEntityTypesClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr SessionEntityTypesClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr SessionEntityTypesClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status SessionEntityTypesClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status SessionEntityTypesClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..187e5648b8d49 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..d6959091e9919 100644 --- a/google/cloud/dialogflow_cx/session_entity_types_connection.cc +++ b/google/cloud/dialogflow_cx/session_entity_types_connection.cc @@ -69,6 +69,39 @@ 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"); +} + +StreamRange +SessionEntityTypesConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +SessionEntityTypesConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status SessionEntityTypesConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSessionEntityTypesConnection( std::string const& location, Options options) { internal::CheckExpectedOptions ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..0ce6dfb8a1fbb 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,31 @@ 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; +} + +Idempotency SessionEntityTypesConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SessionEntityTypesConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency SessionEntityTypesConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..0ecdf38336c8b 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -55,6 +57,21 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..80e58465b0f77 100644 --- a/google/cloud/dialogflow_cx/sessions_client.cc +++ b/google/cloud/dialogflow_cx/sessions_client.cc @@ -81,6 +81,60 @@ 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); +} + +StreamRange SessionsClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange SessionsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr SessionsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr SessionsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status SessionsClient::CancelOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status SessionsClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..6b026a36615c4 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..859f189c99c82 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,36 @@ 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"); +} + +StreamRange SessionsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr SessionsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status SessionsConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSessionsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..ed432032101ff 100644 --- a/google/cloud/dialogflow_cx/sessions_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_cx/sessions_connection_idempotency_policy.cc @@ -54,6 +54,31 @@ 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; +} + +Idempotency SessionsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SessionsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency SessionsConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..018abe47b3c81 100644 --- a/google/cloud/dialogflow_cx/sessions_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_cx/sessions_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 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..4707f673b89a3 100644 --- a/google/cloud/dialogflow_cx/test_cases_client.cc +++ b/google/cloud/dialogflow_cx/test_cases_client.cc @@ -251,6 +251,60 @@ 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); +} + +StreamRange TestCasesClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange TestCasesClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr TestCasesClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr TestCasesClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status TestCasesClient::CancelOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status TestCasesClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..fb9cb0594262c 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..ce669562c3912 100644 --- a/google/cloud/dialogflow_cx/test_cases_connection.cc +++ b/google/cloud/dialogflow_cx/test_cases_connection.cc @@ -176,6 +176,36 @@ 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"); +} + +StreamRange TestCasesConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr TestCasesConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status TestCasesConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeTestCasesConnection( std::string const& location, Options options) { internal::CheckExpectedOptions ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..1ec9bca829a8d 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,31 @@ 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; +} + +Idempotency TestCasesConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency TestCasesConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency TestCasesConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..58a00f42b2dc3 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -75,6 +77,21 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..eba5d5c1b3dd1 100644 --- a/google/cloud/dialogflow_cx/transition_route_groups_client.cc +++ b/google/cloud/dialogflow_cx/transition_route_groups_client.cc @@ -126,6 +126,68 @@ 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); +} + +StreamRange +TransitionRouteGroupsClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +TransitionRouteGroupsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +TransitionRouteGroupsClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +TransitionRouteGroupsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status TransitionRouteGroupsClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status TransitionRouteGroupsClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..c9dfbc9d0c316 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..2c7ce969b08b6 100644 --- a/google/cloud/dialogflow_cx/transition_route_groups_connection.cc +++ b/google/cloud/dialogflow_cx/transition_route_groups_connection.cc @@ -72,6 +72,39 @@ 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"); +} + +StreamRange +TransitionRouteGroupsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +TransitionRouteGroupsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status TransitionRouteGroupsConnection::CancelOperation( + google::longrunning::CancelOperationRequest 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..59649117d382d 100644 --- a/google/cloud/dialogflow_cx/transition_route_groups_connection.h +++ b/google/cloud/dialogflow_cx/transition_route_groups_connection.h @@ -212,6 +212,21 @@ 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..bd230db41a357 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,31 @@ 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; +} + +Idempotency TransitionRouteGroupsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency TransitionRouteGroupsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency TransitionRouteGroupsConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..267f3b226ec66 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -56,6 +58,21 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..7e8181c21c6b5 100644 --- a/google/cloud/dialogflow_cx/versions_client.cc +++ b/google/cloud/dialogflow_cx/versions_client.cc @@ -193,6 +193,60 @@ 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); +} + +StreamRange VersionsClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange VersionsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr VersionsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr VersionsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status VersionsClient::CancelOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status VersionsClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..4cf697804eb39 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..ce3674201c800 100644 --- a/google/cloud/dialogflow_cx/versions_connection.cc +++ b/google/cloud/dialogflow_cx/versions_connection.cc @@ -109,6 +109,36 @@ 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"); +} + +StreamRange VersionsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr VersionsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status VersionsConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeVersionsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..cb543712b1499 100644 --- a/google/cloud/dialogflow_cx/versions_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_cx/versions_connection_idempotency_policy.cc @@ -69,6 +69,31 @@ 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; +} + +Idempotency VersionsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency VersionsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency VersionsConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..7dacaff9f166a 100644 --- a/google/cloud/dialogflow_cx/versions_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_cx/versions_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 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..6f7cded7375c3 100644 --- a/google/cloud/dialogflow_cx/webhooks_client.cc +++ b/google/cloud/dialogflow_cx/webhooks_client.cc @@ -115,6 +115,60 @@ 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); +} + +StreamRange WebhooksClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange WebhooksClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr WebhooksClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr WebhooksClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status WebhooksClient::CancelOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status WebhooksClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..11df710a8c6d7 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..56e15f6e3b9c2 100644 --- a/google/cloud/dialogflow_cx/webhooks_connection.cc +++ b/google/cloud/dialogflow_cx/webhooks_connection.cc @@ -69,6 +69,36 @@ 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"); +} + +StreamRange WebhooksConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr WebhooksConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status WebhooksConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeWebhooksConnection( std::string const& location, Options options) { internal::CheckExpectedOptions ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..7f2047a984c95 100644 --- a/google/cloud/dialogflow_cx/webhooks_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_cx/webhooks_connection_idempotency_policy.cc @@ -59,6 +59,31 @@ 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; +} + +Idempotency WebhooksConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency WebhooksConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency WebhooksConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..9f131147cf944 100644 --- a/google/cloud/dialogflow_cx/webhooks_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_cx/webhooks_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -50,6 +52,21 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..ba4f40da1e70a 100644 --- a/google/cloud/dialogflow_es/agents_client.cc +++ b/google/cloud/dialogflow_es/agents_client.cc @@ -215,6 +215,60 @@ 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); +} + +StreamRange AgentsClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange AgentsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr AgentsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr AgentsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status AgentsClient::CancelOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status AgentsClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..2b5102f7ca9e0 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..2fb9cc637f814 100644 --- a/google/cloud/dialogflow_es/agents_connection.cc +++ b/google/cloud/dialogflow_es/agents_connection.cc @@ -142,6 +142,35 @@ 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"); +} + +StreamRange AgentsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr AgentsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AgentsConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeAgentsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..52207234b9634 100644 --- a/google/cloud/dialogflow_es/agents_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_es/agents_connection_idempotency_policy.cc @@ -79,6 +79,31 @@ 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; +} + +Idempotency AgentsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AgentsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AgentsConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..b1a59cd22b0e0 100644 --- a/google/cloud/dialogflow_es/agents_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_es/agents_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -62,6 +64,21 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..df597b4e9a5ce 100644 --- a/google/cloud/dialogflow_es/answer_records_client.cc +++ b/google/cloud/dialogflow_es/answer_records_client.cc @@ -68,6 +68,62 @@ 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); +} + +StreamRange AnswerRecordsClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange AnswerRecordsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr AnswerRecordsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr AnswerRecordsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status AnswerRecordsClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status AnswerRecordsClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..4747e16a7f348 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..9bc480db01d3d 100644 --- a/google/cloud/dialogflow_es/answer_records_connection.cc +++ b/google/cloud/dialogflow_es/answer_records_connection.cc @@ -52,6 +52,38 @@ 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"); +} + +StreamRange +AnswerRecordsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr AnswerRecordsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AnswerRecordsConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeAnswerRecordsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..525973c1e1a2a 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,31 @@ 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; +} + +Idempotency AnswerRecordsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AnswerRecordsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AnswerRecordsConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..058e1eabb5859 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -42,6 +44,21 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..9352be9e0abad 100644 --- a/google/cloud/dialogflow_es/contexts_client.cc +++ b/google/cloud/dialogflow_es/contexts_client.cc @@ -125,6 +125,60 @@ 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); +} + +StreamRange ContextsClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange ContextsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr ContextsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr ContextsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status ContextsClient::CancelOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status ContextsClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..1870c4c466dde 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..fc6e591af3c61 100644 --- a/google/cloud/dialogflow_es/contexts_connection.cc +++ b/google/cloud/dialogflow_es/contexts_connection.cc @@ -73,6 +73,36 @@ 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"); +} + +StreamRange ContextsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr ContextsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ContextsConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeContextsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..e7078f46418f2 100644 --- a/google/cloud/dialogflow_es/contexts_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_es/contexts_connection_idempotency_policy.cc @@ -64,6 +64,31 @@ 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; +} + +Idempotency ContextsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ContextsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ContextsConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..5c32a64cce4e7 100644 --- a/google/cloud/dialogflow_es/contexts_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_es/contexts_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -53,6 +55,21 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..f20985b4307b4 100644 --- a/google/cloud/dialogflow_es/conversation_datasets_client.cc +++ b/google/cloud/dialogflow_es/conversation_datasets_client.cc @@ -192,6 +192,68 @@ 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); +} + +StreamRange +ConversationDatasetsClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +ConversationDatasetsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +ConversationDatasetsClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +ConversationDatasetsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status ConversationDatasetsClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status ConversationDatasetsClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..cb920c60faff5 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..12be2aad44948 100644 --- a/google/cloud/dialogflow_es/conversation_datasets_connection.cc +++ b/google/cloud/dialogflow_es/conversation_datasets_connection.cc @@ -130,6 +130,39 @@ 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"); +} + +StreamRange +ConversationDatasetsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +ConversationDatasetsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ConversationDatasetsConnection::CancelOperation( + google::longrunning::CancelOperationRequest 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..fa99430519956 100644 --- a/google/cloud/dialogflow_es/conversation_datasets_connection.h +++ b/google/cloud/dialogflow_es/conversation_datasets_connection.h @@ -242,6 +242,21 @@ 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..061b51c64851c 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,31 @@ 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; +} + +Idempotency ConversationDatasetsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ConversationDatasetsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ConversationDatasetsConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..91f66c445a335 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -55,6 +57,21 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..d306dd7ab4e1f 100644 --- a/google/cloud/dialogflow_es/conversation_models_client.cc +++ b/google/cloud/dialogflow_es/conversation_models_client.cc @@ -313,6 +313,66 @@ 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); +} + +StreamRange +ConversationModelsClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +ConversationModelsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr ConversationModelsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr ConversationModelsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status ConversationModelsClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status ConversationModelsClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..e8239dd4fa69c 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..8d59cad7356a9 100644 --- a/google/cloud/dialogflow_es/conversation_models_connection.cc +++ b/google/cloud/dialogflow_es/conversation_models_connection.cc @@ -196,6 +196,39 @@ 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"); +} + +StreamRange +ConversationModelsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +ConversationModelsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ConversationModelsConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeConversationModelsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions> CreateConversationModelEvaluation( google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..e65bceea286f3 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,31 @@ 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; +} + +Idempotency ConversationModelsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ConversationModelsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ConversationModelsConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..b6a90141cfa1c 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -71,6 +73,21 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..06aeb0c5fc51b 100644 --- a/google/cloud/dialogflow_es/conversation_profiles_client.cc +++ b/google/cloud/dialogflow_es/conversation_profiles_client.cc @@ -273,6 +273,68 @@ 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); +} + +StreamRange +ConversationProfilesClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +ConversationProfilesClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +ConversationProfilesClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +ConversationProfilesClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status ConversationProfilesClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status ConversationProfilesClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..f12eb6e191028 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..4d4cad7c1a0c3 100644 --- a/google/cloud/dialogflow_es/conversation_profiles_connection.cc +++ b/google/cloud/dialogflow_es/conversation_profiles_connection.cc @@ -117,6 +117,39 @@ 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"); +} + +StreamRange +ConversationProfilesConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +ConversationProfilesConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ConversationProfilesConnection::CancelOperation( + google::longrunning::CancelOperationRequest 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..75eafc20599f0 100644 --- a/google/cloud/dialogflow_es/conversation_profiles_connection.h +++ b/google/cloud/dialogflow_es/conversation_profiles_connection.h @@ -239,6 +239,21 @@ 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..bdad98b4c619a 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,31 @@ 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; +} + +Idempotency ConversationProfilesConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ConversationProfilesConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ConversationProfilesConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..613836222d388 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -63,6 +65,21 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..582342315b279 100644 --- a/google/cloud/dialogflow_es/conversations_client.cc +++ b/google/cloud/dialogflow_es/conversations_client.cc @@ -161,6 +161,62 @@ 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); +} + +StreamRange ConversationsClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange ConversationsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr ConversationsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr ConversationsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status ConversationsClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status ConversationsClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..a6f0b55999df3 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..e9b9c7ac6f747 100644 --- a/google/cloud/dialogflow_es/conversations_connection.cc +++ b/google/cloud/dialogflow_es/conversations_connection.cc @@ -96,6 +96,38 @@ 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"); +} + +StreamRange +ConversationsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr ConversationsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ConversationsConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeConversationsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..53e1544b5d732 100644 --- a/google/cloud/dialogflow_es/conversations_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_es/conversations_connection_idempotency_policy.cc @@ -81,6 +81,31 @@ 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; +} + +Idempotency ConversationsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ConversationsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ConversationsConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..f7dc3b2923c22 100644 --- a/google/cloud/dialogflow_es/conversations_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_es/conversations_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -67,6 +69,21 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..d9f4c58904792 100644 --- a/google/cloud/dialogflow_es/documents_client.cc +++ b/google/cloud/dialogflow_es/documents_client.cc @@ -278,6 +278,60 @@ 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); +} + +StreamRange DocumentsClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange DocumentsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr DocumentsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr DocumentsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status DocumentsClient::CancelOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status DocumentsClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..0339caea9fd4f 100644 --- a/google/cloud/dialogflow_es/documents_client.h +++ b/google/cloud/dialogflow_es/documents_client.h @@ -932,6 +932,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..30324bb54d901 100644 --- a/google/cloud/dialogflow_es/documents_connection.cc +++ b/google/cloud/dialogflow_es/documents_connection.cc @@ -178,6 +178,36 @@ 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"); +} + +StreamRange DocumentsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr DocumentsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DocumentsConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDocumentsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions> ExportDocument(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..4172e83082c7f 100644 --- a/google/cloud/dialogflow_es/documents_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_es/documents_connection_idempotency_policy.cc @@ -74,6 +74,31 @@ 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; +} + +Idempotency DocumentsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DocumentsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DocumentsConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..df6e2052946c9 100644 --- a/google/cloud/dialogflow_es/documents_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_es/documents_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 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..3c95cbd4ee690 100644 --- a/google/cloud/dialogflow_es/entity_types_client.cc +++ b/google/cloud/dialogflow_es/entity_types_client.cc @@ -457,6 +457,61 @@ 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); +} + +StreamRange EntityTypesClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange EntityTypesClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr EntityTypesClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr EntityTypesClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status EntityTypesClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status EntityTypesClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..9bb1bb62b5f32 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..ab982026656d0 100644 --- a/google/cloud/dialogflow_es/entity_types_connection.cc +++ b/google/cloud/dialogflow_es/entity_types_connection.cc @@ -181,6 +181,37 @@ 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"); +} + +StreamRange +EntityTypesConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr EntityTypesConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status EntityTypesConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeEntityTypesConnection( std::string const& location, Options options) { internal::CheckExpectedOptions> BatchDeleteEntities( google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..fe0a06dbb44ab 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,31 @@ 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; +} + +Idempotency EntityTypesConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency EntityTypesConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency EntityTypesConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..7e896ea74d661 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -67,6 +69,21 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..03a32e28783e4 100644 --- a/google/cloud/dialogflow_es/environments_client.cc +++ b/google/cloud/dialogflow_es/environments_client.cc @@ -87,6 +87,62 @@ 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); +} + +StreamRange EnvironmentsClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange EnvironmentsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr EnvironmentsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr EnvironmentsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status EnvironmentsClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status EnvironmentsClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..11812dcf86c29 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..bd824739ec00e 100644 --- a/google/cloud/dialogflow_es/environments_connection.cc +++ b/google/cloud/dialogflow_es/environments_connection.cc @@ -77,6 +77,37 @@ 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"); +} + +StreamRange +EnvironmentsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr EnvironmentsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status EnvironmentsConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeEnvironmentsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions GetEnvironmentHistory( google::cloud::dialogflow::v2::GetEnvironmentHistoryRequest request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..ae1760f21d537 100644 --- a/google/cloud/dialogflow_es/environments_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_es/environments_connection_idempotency_policy.cc @@ -64,6 +64,31 @@ 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; +} + +Idempotency EnvironmentsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency EnvironmentsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency EnvironmentsConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..5ce5ef5ac37d4 100644 --- a/google/cloud/dialogflow_es/environments_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_es/environments_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 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..7d1d07a84903a 100644 --- a/google/cloud/dialogflow_es/fulfillments_client.cc +++ b/google/cloud/dialogflow_es/fulfillments_client.cc @@ -67,6 +67,62 @@ 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); +} + +StreamRange FulfillmentsClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange FulfillmentsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr FulfillmentsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr FulfillmentsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status FulfillmentsClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status FulfillmentsClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..c60b61b5bd890 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..7afe80a7e52c7 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,37 @@ 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"); +} + +StreamRange +FulfillmentsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr FulfillmentsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status FulfillmentsConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeFulfillmentsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions #include @@ -188,6 +189,21 @@ 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..362f68b83407d 100644 --- a/google/cloud/dialogflow_es/fulfillments_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_es/fulfillments_connection_idempotency_policy.cc @@ -44,6 +44,31 @@ 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; +} + +Idempotency FulfillmentsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency FulfillmentsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency FulfillmentsConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..5e6e3dc407104 100644 --- a/google/cloud/dialogflow_es/fulfillments_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_es/fulfillments_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 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..60548ef963952 100644 --- a/google/cloud/dialogflow_es/intents_client.cc +++ b/google/cloud/dialogflow_es/intents_client.cc @@ -261,6 +261,60 @@ 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); +} + +StreamRange IntentsClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange IntentsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr IntentsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr IntentsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status IntentsClient::CancelOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status IntentsClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..ba2b4e4d03531 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..b84bfae80df57 100644 --- a/google/cloud/dialogflow_es/intents_connection.cc +++ b/google/cloud/dialogflow_es/intents_connection.cc @@ -108,6 +108,35 @@ 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"); +} + +StreamRange IntentsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr IntentsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status IntentsConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeIntentsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions> BatchDeleteIntents( google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..e8c83f06694e9 100644 --- a/google/cloud/dialogflow_es/intents_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_es/intents_connection_idempotency_policy.cc @@ -69,6 +69,31 @@ 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; +} + +Idempotency IntentsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency IntentsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency IntentsConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..ce1be9ae11824 100644 --- a/google/cloud/dialogflow_es/intents_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_es/intents_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 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..f886bc170b823 100644 --- a/google/cloud/dialogflow_es/internal/agents_auth_decorator.cc +++ b/google/cloud/dialogflow_es/internal/agents_auth_decorator.cc @@ -181,6 +181,48 @@ 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); +} + +StatusOr +AgentsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr AgentsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status AgentsAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..60a1c64685fed 100644 --- a/google/cloud/dialogflow_es/internal/agents_auth_decorator.h +++ b/google/cloud/dialogflow_es/internal/agents_auth_decorator.h @@ -107,6 +107,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..10823e8bb7ea4 100644 --- a/google/cloud/dialogflow_es/internal/agents_connection_impl.cc +++ b/google/cloud/dialogflow_es/internal/agents_connection_impl.cc @@ -498,6 +498,112 @@ 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__); +} + +StreamRange +AgentsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr AgentsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status AgentsConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..780687645c700 100644 --- a/google/cloud/dialogflow_es/internal/agents_connection_impl.h +++ b/google/cloud/dialogflow_es/internal/agents_connection_impl.h @@ -113,6 +113,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..eb7df10f992db 100644 --- a/google/cloud/dialogflow_es/internal/agents_logging_decorator.cc +++ b/google/cloud/dialogflow_es/internal/agents_logging_decorator.cc @@ -211,6 +211,63 @@ 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_); +} + +StatusOr +AgentsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AgentsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AgentsLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..80f19c5ccbece 100644 --- a/google/cloud/dialogflow_es/internal/agents_logging_decorator.h +++ b/google/cloud/dialogflow_es/internal/agents_logging_decorator.h @@ -107,6 +107,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..3613340f24fc2 100644 --- a/google/cloud/dialogflow_es/internal/agents_metadata_decorator.cc +++ b/google/cloud/dialogflow_es/internal/agents_metadata_decorator.cc @@ -167,6 +167,48 @@ 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); +} + +StatusOr +AgentsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr AgentsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status AgentsMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..4ed41e60e0826 100644 --- a/google/cloud/dialogflow_es/internal/agents_metadata_decorator.h +++ b/google/cloud/dialogflow_es/internal/agents_metadata_decorator.h @@ -107,6 +107,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..f72c41d0b92f3 100644 --- a/google/cloud/dialogflow_es/internal/agents_stub.cc +++ b/google/cloud/dialogflow_es/internal/agents_stub.cc @@ -204,6 +204,63 @@ 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; +} + +StatusOr +DefaultAgentsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAgentsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultAgentsStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..9192b5b3c390e 100644 --- a/google/cloud/dialogflow_es/internal/agents_stub.h +++ b/google/cloud/dialogflow_es/internal/agents_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -102,6 +103,27 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -120,9 +142,16 @@ class DefaultAgentsStub : public AgentsStub { DefaultAgentsStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr GetAgent( grpc::ClientContext& context, Options const& options, @@ -192,6 +221,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -207,6 +256,10 @@ class DefaultAgentsStub : public AgentsStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..113605d9e8ea1 100644 --- a/google/cloud/dialogflow_es/internal/agents_stub_factory.cc +++ b/google/cloud/dialogflow_es/internal/agents_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 CreateDefaultAgentsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::Agents::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..ce20dd6f8af5e 100644 --- a/google/cloud/dialogflow_es/internal/agents_tracing_connection.cc +++ b/google/cloud/dialogflow_es/internal/agents_tracing_connection.cc @@ -178,6 +178,53 @@ 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)); +} + +StreamRange +AgentsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_es::AgentsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr AgentsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_es::AgentsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status AgentsTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_es::AgentsConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..01f3d4b5d2a15 100644 --- a/google/cloud/dialogflow_es/internal/agents_tracing_connection.h +++ b/google/cloud/dialogflow_es/internal/agents_tracing_connection.h @@ -101,6 +101,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..d0d7ff8dd5606 100644 --- a/google/cloud/dialogflow_es/internal/agents_tracing_stub.cc +++ b/google/cloud/dialogflow_es/internal/agents_tracing_stub.cc @@ -188,6 +188,63 @@ 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)); +} + +StatusOr +AgentsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Agents", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr AgentsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Agents", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status AgentsTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Agents", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..f822514aa1635 100644 --- a/google/cloud/dialogflow_es/internal/agents_tracing_stub.h +++ b/google/cloud/dialogflow_es/internal/agents_tracing_stub.h @@ -106,6 +106,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..e7eb32a9b5b5e 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,48 @@ 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); +} + +StatusOr +AnswerRecordsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr AnswerRecordsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status AnswerRecordsAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..9c8914a680960 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..5f7c9bfa0da9b 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,114 @@ 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__); +} + +StreamRange +AnswerRecordsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +AnswerRecordsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status AnswerRecordsConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..1dd48a5aefcfb 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..3d228f681f4c9 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,63 @@ 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_); +} + +StatusOr +AnswerRecordsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AnswerRecordsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AnswerRecordsLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..19d3068dcfd86 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..9a67143f97cd4 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,48 @@ 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); +} + +StatusOr +AnswerRecordsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr AnswerRecordsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status AnswerRecordsMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..294eb6df4ad08 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..5eefeb85545ed 100644 --- a/google/cloud/dialogflow_es/internal/answer_records_stub.cc +++ b/google/cloud/dialogflow_es/internal/answer_records_stub.cc @@ -54,6 +54,64 @@ 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; +} + +StatusOr +DefaultAnswerRecordsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAnswerRecordsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultAnswerRecordsStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..b5d2e25113524 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,27 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultAnswerRecordsStub : public AnswerRecordsStub { @@ -53,8 +76,14 @@ 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 + operations_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListAnswerRecords( @@ -67,9 +96,33 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..ad318881d723c 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,8 +46,14 @@ std::shared_ptr CreateDefaultAnswerRecordsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::AnswerRecords::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..017760478a98b 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,54 @@ 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)); +} + +StreamRange +AnswerRecordsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_es::AnswerRecordsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AnswerRecordsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_es::AnswerRecordsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status AnswerRecordsTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_es::AnswerRecordsConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..053a893330b28 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..f3cf17b00bd9b 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,64 @@ 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)); +} + +StatusOr +AnswerRecordsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.AnswerRecords", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr AnswerRecordsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.AnswerRecords", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status AnswerRecordsTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.AnswerRecords", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..4a25399c4bcaf 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..f41fea037d147 100644 --- a/google/cloud/dialogflow_es/internal/contexts_auth_decorator.cc +++ b/google/cloud/dialogflow_es/internal/contexts_auth_decorator.cc @@ -80,6 +80,48 @@ 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); +} + +StatusOr +ContextsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr ContextsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status ContextsAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..948b923b60eac 100644 --- a/google/cloud/dialogflow_es/internal/contexts_auth_decorator.h +++ b/google/cloud/dialogflow_es/internal/contexts_auth_decorator.h @@ -67,6 +67,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..44a672a5b4291 100644 --- a/google/cloud/dialogflow_es/internal/contexts_connection_impl.cc +++ b/google/cloud/dialogflow_es/internal/contexts_connection_impl.cc @@ -164,6 +164,112 @@ 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__); +} + +StreamRange +ContextsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr ContextsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ContextsConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..e2d1201ecbb5b 100644 --- a/google/cloud/dialogflow_es/internal/contexts_connection_impl.h +++ b/google/cloud/dialogflow_es/internal/contexts_connection_impl.h @@ -70,6 +70,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..fe66c6e82f291 100644 --- a/google/cloud/dialogflow_es/internal/contexts_logging_decorator.cc +++ b/google/cloud/dialogflow_es/internal/contexts_logging_decorator.cc @@ -107,6 +107,63 @@ 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_); +} + +StatusOr +ContextsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ContextsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ContextsLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..7e5977dbbeeb7 100644 --- a/google/cloud/dialogflow_es/internal/contexts_logging_decorator.h +++ b/google/cloud/dialogflow_es/internal/contexts_logging_decorator.h @@ -67,6 +67,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..2f43012a9c0be 100644 --- a/google/cloud/dialogflow_es/internal/contexts_metadata_decorator.cc +++ b/google/cloud/dialogflow_es/internal/contexts_metadata_decorator.cc @@ -96,6 +96,48 @@ 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); +} + +StatusOr +ContextsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr ContextsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status ContextsMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..7ce93cb189d2a 100644 --- a/google/cloud/dialogflow_es/internal/contexts_metadata_decorator.h +++ b/google/cloud/dialogflow_es/internal/contexts_metadata_decorator.h @@ -67,6 +67,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..69d6806604a97 100644 --- a/google/cloud/dialogflow_es/internal/contexts_stub.cc +++ b/google/cloud/dialogflow_es/internal/contexts_stub.cc @@ -100,6 +100,63 @@ 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; +} + +StatusOr +DefaultContextsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultContextsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultContextsStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..22b8dbf264a08 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,41 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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 + operations_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListContexts( grpc::ClientContext& context, Options const& options, @@ -98,9 +127,33 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..729866f97cee2 100644 --- a/google/cloud/dialogflow_es/internal/contexts_stub_factory.cc +++ b/google/cloud/dialogflow_es/internal/contexts_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 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_operations_stub = + google::longrunning::Operations::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_operations_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..f41d06741313e 100644 --- a/google/cloud/dialogflow_es/internal/contexts_tracing_connection.cc +++ b/google/cloud/dialogflow_es/internal/contexts_tracing_connection.cc @@ -87,6 +87,54 @@ 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)); +} + +StreamRange +ContextsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_es::ContextsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ContextsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_es::ContextsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status ContextsTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_es::ContextsConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..96ea4b943c562 100644 --- a/google/cloud/dialogflow_es/internal/contexts_tracing_connection.h +++ b/google/cloud/dialogflow_es/internal/contexts_tracing_connection.h @@ -61,6 +61,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..f03a75f891c53 100644 --- a/google/cloud/dialogflow_es/internal/contexts_tracing_stub.cc +++ b/google/cloud/dialogflow_es/internal/contexts_tracing_stub.cc @@ -101,6 +101,63 @@ 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)); +} + +StatusOr +ContextsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Contexts", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr ContextsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Contexts", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status ContextsTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Contexts", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..87fe72f5074c8 100644 --- a/google/cloud/dialogflow_es/internal/contexts_tracing_stub.h +++ b/google/cloud/dialogflow_es/internal/contexts_tracing_stub.h @@ -67,6 +67,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..f3ada29605abf 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,49 @@ 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); +} + +StatusOr +ConversationDatasetsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr ConversationDatasetsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status ConversationDatasetsAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..2667217e7180c 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..6dba4bfe37de5 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,114 @@ 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__); +} + +StreamRange +ConversationDatasetsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ConversationDatasetsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ConversationDatasetsConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..8d2b57f45589a 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..6e7962f40d20f 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,65 @@ 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_); +} + +StatusOr +ConversationDatasetsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ConversationDatasetsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ConversationDatasetsLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..e9a949fd6cc31 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..824bee67453af 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,50 @@ 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); +} + +StatusOr +ConversationDatasetsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +ConversationDatasetsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status ConversationDatasetsMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..48774ba5427d0 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..e229685280de0 100644 --- a/google/cloud/dialogflow_es/internal/conversation_datasets_stub.cc +++ b/google/cloud/dialogflow_es/internal/conversation_datasets_stub.cc @@ -163,6 +163,65 @@ 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; +} + +StatusOr +DefaultConversationDatasetsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultConversationDatasetsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultConversationDatasetsStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..c3ad819dd3325 100644 --- a/google/cloud/dialogflow_es/internal/conversation_datasets_stub.h +++ b/google/cloud/dialogflow_es/internal/conversation_datasets_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -90,6 +91,27 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -109,9 +131,16 @@ class DefaultConversationDatasetsStub : public ConversationDatasetsStub { std::unique_ptr< google::cloud::dialogflow::v2::ConversationDatasets::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateConversationDataset( @@ -163,6 +192,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -179,6 +228,10 @@ class DefaultConversationDatasetsStub : public ConversationDatasetsStub { std::unique_ptr< google::cloud::dialogflow::v2::ConversationDatasets::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..0b25dffd089dd 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,14 @@ std::shared_ptr CreateDefaultConversationDatasetsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::ConversationDatasets::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..d9cc70dc3e7f2 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,54 @@ 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)); +} + +StreamRange +ConversationDatasetsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_es::ConversationDatasetsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ConversationDatasetsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_es::ConversationDatasetsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status ConversationDatasetsTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_es::ConversationDatasetsConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..48920e83f816d 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..7dead452e5ea5 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,65 @@ 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)); +} + +StatusOr +ConversationDatasetsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.v2.ConversationDatasets", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +ConversationDatasetsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.v2.ConversationDatasets", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status ConversationDatasetsTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.v2.ConversationDatasets", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..8d42999214a57 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..aae3b5e7796a9 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,48 @@ 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); +} + +StatusOr +ConversationModelsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr ConversationModelsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status ConversationModelsAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..65965652491ea 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..1bfc11bb087da 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,114 @@ 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__); +} + +StreamRange +ConversationModelsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ConversationModelsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ConversationModelsConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..de3fdd28ff5ce 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..e1d7777fef097 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,65 @@ 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_); +} + +StatusOr +ConversationModelsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ConversationModelsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ConversationModelsLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..1c5ac09d0bd3b 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..8c35ce72ee964 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,50 @@ 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); +} + +StatusOr +ConversationModelsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +ConversationModelsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status ConversationModelsMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..ee1827b663aa7 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..5e9adfa10c1c3 100644 --- a/google/cloud/dialogflow_es/internal/conversation_models_stub.cc +++ b/google/cloud/dialogflow_es/internal/conversation_models_stub.cc @@ -262,6 +262,65 @@ 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; +} + +StatusOr +DefaultConversationModelsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultConversationModelsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultConversationModelsStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..c56cfd3d9453c 100644 --- a/google/cloud/dialogflow_es/internal/conversation_models_stub.h +++ b/google/cloud/dialogflow_es/internal/conversation_models_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -130,6 +131,27 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -149,9 +171,16 @@ class DefaultConversationModelsStub : public ConversationModelsStub { std::unique_ptr< google::cloud::dialogflow::v2::ConversationModels::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateConversationModel( google::cloud::CompletionQueue& cq, @@ -240,6 +269,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -256,6 +305,10 @@ class DefaultConversationModelsStub : public ConversationModelsStub { std::unique_ptr< google::cloud::dialogflow::v2::ConversationModels::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..b9d66a90addad 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,14 @@ std::shared_ptr CreateDefaultConversationModelsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::ConversationModels::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..5afa2351d1a59 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,54 @@ 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)); +} + +StreamRange +ConversationModelsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_es::ConversationModelsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ConversationModelsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_es::ConversationModelsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status ConversationModelsTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_es::ConversationModelsConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..441c40a290e11 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..9f1e7af19914c 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,65 @@ 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)); +} + +StatusOr +ConversationModelsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.v2.ConversationModels", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +ConversationModelsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.v2.ConversationModels", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status ConversationModelsTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.v2.ConversationModels", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..6ab727cd8f9e2 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..8cf6b4fd78450 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,49 @@ 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); +} + +StatusOr +ConversationProfilesAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr ConversationProfilesAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status ConversationProfilesAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..a52ea337d249e 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..7f65391b22a4c 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,114 @@ 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__); +} + +StreamRange +ConversationProfilesConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ConversationProfilesConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ConversationProfilesConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..ba2829b44a97c 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..64140d2088831 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,65 @@ 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_); +} + +StatusOr +ConversationProfilesLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ConversationProfilesLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ConversationProfilesLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..a0f85a9e3e494 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..bbc01deac5cc4 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,50 @@ 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); +} + +StatusOr +ConversationProfilesMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +ConversationProfilesMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status ConversationProfilesMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..ce623f0bc6ead 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..c5955f1cbd1ce 100644 --- a/google/cloud/dialogflow_es/internal/conversation_profiles_stub.cc +++ b/google/cloud/dialogflow_es/internal/conversation_profiles_stub.cc @@ -170,6 +170,65 @@ 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; +} + +StatusOr +DefaultConversationProfilesStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultConversationProfilesStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultConversationProfilesStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..af4e56fb001f1 100644 --- a/google/cloud/dialogflow_es/internal/conversation_profiles_stub.h +++ b/google/cloud/dialogflow_es/internal/conversation_profiles_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -94,6 +95,27 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -113,9 +135,16 @@ class DefaultConversationProfilesStub : public ConversationProfilesStub { std::unique_ptr< google::cloud::dialogflow::v2::ConversationProfiles::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListConversationProfiles( @@ -172,6 +201,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -188,6 +237,10 @@ class DefaultConversationProfilesStub : public ConversationProfilesStub { std::unique_ptr< google::cloud::dialogflow::v2::ConversationProfiles::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..906c0e3cb6f96 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,14 @@ std::shared_ptr CreateDefaultConversationProfilesStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::ConversationProfiles::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..514db7e718199 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,54 @@ 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)); +} + +StreamRange +ConversationProfilesTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_es::ConversationProfilesConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ConversationProfilesTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_es::ConversationProfilesConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status ConversationProfilesTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_es::ConversationProfilesConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..5a994ec4737d0 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..6445f6e6e9873 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,65 @@ 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)); +} + +StatusOr +ConversationProfilesTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.v2.ConversationProfiles", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +ConversationProfilesTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.v2.ConversationProfiles", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status ConversationProfilesTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.v2.ConversationProfiles", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..9994722b6a7d5 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..b9a120d630ae8 100644 --- a/google/cloud/dialogflow_es/internal/conversations_auth_decorator.cc +++ b/google/cloud/dialogflow_es/internal/conversations_auth_decorator.cc @@ -115,6 +115,48 @@ 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); +} + +StatusOr +ConversationsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr ConversationsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status ConversationsAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..982e19936109d 100644 --- a/google/cloud/dialogflow_es/internal/conversations_auth_decorator.h +++ b/google/cloud/dialogflow_es/internal/conversations_auth_decorator.h @@ -87,6 +87,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..14041a2f8e550 100644 --- a/google/cloud/dialogflow_es/internal/conversations_connection_impl.cc +++ b/google/cloud/dialogflow_es/internal/conversations_connection_impl.cc @@ -238,6 +238,114 @@ 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__); +} + +StreamRange +ConversationsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ConversationsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ConversationsConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..05beed90b4ad3 100644 --- a/google/cloud/dialogflow_es/internal/conversations_connection_impl.h +++ b/google/cloud/dialogflow_es/internal/conversations_connection_impl.h @@ -86,6 +86,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..ce4547fa0c243 100644 --- a/google/cloud/dialogflow_es/internal/conversations_logging_decorator.cc +++ b/google/cloud/dialogflow_es/internal/conversations_logging_decorator.cc @@ -156,6 +156,63 @@ 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_); +} + +StatusOr +ConversationsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ConversationsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ConversationsLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..d36fb043e2971 100644 --- a/google/cloud/dialogflow_es/internal/conversations_logging_decorator.h +++ b/google/cloud/dialogflow_es/internal/conversations_logging_decorator.h @@ -87,6 +87,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..e2be84b81ce68 100644 --- a/google/cloud/dialogflow_es/internal/conversations_metadata_decorator.cc +++ b/google/cloud/dialogflow_es/internal/conversations_metadata_decorator.cc @@ -131,6 +131,48 @@ 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); +} + +StatusOr +ConversationsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr ConversationsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status ConversationsMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..61d647dfbf210 100644 --- a/google/cloud/dialogflow_es/internal/conversations_metadata_decorator.h +++ b/google/cloud/dialogflow_es/internal/conversations_metadata_decorator.h @@ -87,6 +87,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..d39688c17ab55 100644 --- a/google/cloud/dialogflow_es/internal/conversations_stub.cc +++ b/google/cloud/dialogflow_es/internal/conversations_stub.cc @@ -144,6 +144,64 @@ 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; +} + +StatusOr +DefaultConversationsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultConversationsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultConversationsStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..847219b2085f9 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,27 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultConversationsStub : public ConversationsStub { @@ -94,8 +117,14 @@ 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 + operations_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr CreateConversation( grpc::ClientContext& context, Options const& options, @@ -146,9 +175,33 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..4d91f838a99c1 100644 --- a/google/cloud/dialogflow_es/internal/conversations_stub_factory.cc +++ b/google/cloud/dialogflow_es/internal/conversations_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,14 @@ std::shared_ptr CreateDefaultConversationsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::Conversations::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..55327d5a8d11d 100644 --- a/google/cloud/dialogflow_es/internal/conversations_tracing_connection.cc +++ b/google/cloud/dialogflow_es/internal/conversations_tracing_connection.cc @@ -122,6 +122,54 @@ 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)); +} + +StreamRange +ConversationsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_es::ConversationsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ConversationsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_es::ConversationsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status ConversationsTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_es::ConversationsConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..1650923c447bb 100644 --- a/google/cloud/dialogflow_es/internal/conversations_tracing_connection.h +++ b/google/cloud/dialogflow_es/internal/conversations_tracing_connection.h @@ -77,6 +77,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..0be327a72062c 100644 --- a/google/cloud/dialogflow_es/internal/conversations_tracing_stub.cc +++ b/google/cloud/dialogflow_es/internal/conversations_tracing_stub.cc @@ -146,6 +146,64 @@ 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)); +} + +StatusOr +ConversationsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Conversations", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr ConversationsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Conversations", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status ConversationsTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Conversations", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..fd18425132060 100644 --- a/google/cloud/dialogflow_es/internal/conversations_tracing_stub.h +++ b/google/cloud/dialogflow_es/internal/conversations_tracing_stub.h @@ -87,6 +87,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..251c9ecb6e744 100644 --- a/google/cloud/dialogflow_es/internal/documents_auth_decorator.cc +++ b/google/cloud/dialogflow_es/internal/documents_auth_decorator.cc @@ -216,6 +216,48 @@ 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); +} + +StatusOr +DocumentsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr DocumentsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status DocumentsAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..fe7d36473fd79 100644 --- a/google/cloud/dialogflow_es/internal/documents_auth_decorator.h +++ b/google/cloud/dialogflow_es/internal/documents_auth_decorator.h @@ -121,6 +121,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..c54b2e1149148 100644 --- a/google/cloud/dialogflow_es/internal/documents_connection_impl.cc +++ b/google/cloud/dialogflow_es/internal/documents_connection_impl.cc @@ -667,6 +667,113 @@ 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__); +} + +StreamRange +DocumentsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr DocumentsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DocumentsConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..c753e4c642757 100644 --- a/google/cloud/dialogflow_es/internal/documents_connection_impl.h +++ b/google/cloud/dialogflow_es/internal/documents_connection_impl.h @@ -130,6 +130,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..657a9b07f70d4 100644 --- a/google/cloud/dialogflow_es/internal/documents_logging_decorator.cc +++ b/google/cloud/dialogflow_es/internal/documents_logging_decorator.cc @@ -245,6 +245,63 @@ 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_); +} + +StatusOr +DocumentsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DocumentsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DocumentsLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..ea5a5fe94d2ae 100644 --- a/google/cloud/dialogflow_es/internal/documents_logging_decorator.h +++ b/google/cloud/dialogflow_es/internal/documents_logging_decorator.h @@ -121,6 +121,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..e39a8d4b9875d 100644 --- a/google/cloud/dialogflow_es/internal/documents_metadata_decorator.cc +++ b/google/cloud/dialogflow_es/internal/documents_metadata_decorator.cc @@ -184,6 +184,48 @@ 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); +} + +StatusOr +DocumentsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr DocumentsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status DocumentsMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..e7d7390fa1011 100644 --- a/google/cloud/dialogflow_es/internal/documents_metadata_decorator.h +++ b/google/cloud/dialogflow_es/internal/documents_metadata_decorator.h @@ -121,6 +121,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..e03a01ec0b1a1 100644 --- a/google/cloud/dialogflow_es/internal/documents_stub.cc +++ b/google/cloud/dialogflow_es/internal/documents_stub.cc @@ -235,6 +235,63 @@ 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; +} + +StatusOr +DefaultDocumentsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultDocumentsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultDocumentsStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..566c47574a867 100644 --- a/google/cloud/dialogflow_es/internal/documents_stub.h +++ b/google/cloud/dialogflow_es/internal/documents_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -107,6 +108,27 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -125,9 +147,16 @@ class DefaultDocumentsStub : public DocumentsStub { DefaultDocumentsStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListDocuments( grpc::ClientContext& context, Options const& options, @@ -211,6 +240,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -226,6 +275,10 @@ class DefaultDocumentsStub : public DocumentsStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..70b1caa452503 100644 --- a/google/cloud/dialogflow_es/internal/documents_stub_factory.cc +++ b/google/cloud/dialogflow_es/internal/documents_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 CreateDefaultDocumentsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::Documents::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..310bd2aebfcc6 100644 --- a/google/cloud/dialogflow_es/internal/documents_tracing_connection.cc +++ b/google/cloud/dialogflow_es/internal/documents_tracing_connection.cc @@ -227,6 +227,54 @@ 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)); +} + +StreamRange +DocumentsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_es::DocumentsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DocumentsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_es::DocumentsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status DocumentsTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_es::DocumentsConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..75fde695e6d68 100644 --- a/google/cloud/dialogflow_es/internal/documents_tracing_connection.h +++ b/google/cloud/dialogflow_es/internal/documents_tracing_connection.h @@ -118,6 +118,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..515bf7b8a7cea 100644 --- a/google/cloud/dialogflow_es/internal/documents_tracing_stub.cc +++ b/google/cloud/dialogflow_es/internal/documents_tracing_stub.cc @@ -211,6 +211,63 @@ 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)); +} + +StatusOr +DocumentsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Documents", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr DocumentsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Documents", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status DocumentsTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Documents", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..5927be7b7d580 100644 --- a/google/cloud/dialogflow_es/internal/documents_tracing_stub.h +++ b/google/cloud/dialogflow_es/internal/documents_tracing_stub.h @@ -120,6 +120,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..e18b96df1208b 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,48 @@ 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); +} + +StatusOr +EntityTypesAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr EntityTypesAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status EntityTypesAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..698a8a8a4428a 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..e4e4e8ff56ac8 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,114 @@ 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__); +} + +StreamRange +EntityTypesConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +EntityTypesConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status EntityTypesConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..4a9280b2e717e 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..3ed5626d268c0 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,63 @@ 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_); +} + +StatusOr +EntityTypesLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr EntityTypesLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status EntityTypesLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..a1710cabff46e 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..a66c2633812b1 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,48 @@ 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); +} + +StatusOr +EntityTypesMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr EntityTypesMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status EntityTypesMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..05cc16bc3db4c 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..d5c76850d382a 100644 --- a/google/cloud/dialogflow_es/internal/entity_types_stub.cc +++ b/google/cloud/dialogflow_es/internal/entity_types_stub.cc @@ -251,6 +251,63 @@ 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; +} + +StatusOr +DefaultEntityTypesStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultEntityTypesStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultEntityTypesStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..dfaf0caccac0e 100644 --- a/google/cloud/dialogflow_es/internal/entity_types_stub.h +++ b/google/cloud/dialogflow_es/internal/entity_types_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -128,6 +129,27 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -146,9 +168,16 @@ class DefaultEntityTypesStub : public EntityTypesStub { DefaultEntityTypesStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListEntityTypes(grpc::ClientContext& context, Options const& options, @@ -235,6 +264,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -250,6 +299,10 @@ class DefaultEntityTypesStub : public EntityTypesStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..68c846e711f4e 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,14 @@ std::shared_ptr CreateDefaultEntityTypesStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::EntityTypes::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..9b25e9c24b759 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,54 @@ 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)); +} + +StreamRange +EntityTypesTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_es::EntityTypesConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +EntityTypesTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_es::EntityTypesConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status EntityTypesTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_es::EntityTypesConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..c7a451a91bdca 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..2bf773d17b70e 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,63 @@ 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)); +} + +StatusOr +EntityTypesTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.EntityTypes", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr EntityTypesTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.EntityTypes", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status EntityTypesTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.EntityTypes", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..7757f7f17f880 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..3894d472a633f 100644 --- a/google/cloud/dialogflow_es/internal/environments_auth_decorator.cc +++ b/google/cloud/dialogflow_es/internal/environments_auth_decorator.cc @@ -85,6 +85,48 @@ 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); +} + +StatusOr +EnvironmentsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr EnvironmentsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status EnvironmentsAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..f9b95c96e86f4 100644 --- a/google/cloud/dialogflow_es/internal/environments_auth_decorator.h +++ b/google/cloud/dialogflow_es/internal/environments_auth_decorator.h @@ -69,6 +69,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..ee751e6f18359 100644 --- a/google/cloud/dialogflow_es/internal/environments_connection_impl.cc +++ b/google/cloud/dialogflow_es/internal/environments_connection_impl.cc @@ -188,6 +188,114 @@ 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__); +} + +StreamRange +EnvironmentsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +EnvironmentsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status EnvironmentsConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..611e99e1a349d 100644 --- a/google/cloud/dialogflow_es/internal/environments_connection_impl.h +++ b/google/cloud/dialogflow_es/internal/environments_connection_impl.h @@ -73,6 +73,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..355d13a9e34bf 100644 --- a/google/cloud/dialogflow_es/internal/environments_logging_decorator.cc +++ b/google/cloud/dialogflow_es/internal/environments_logging_decorator.cc @@ -113,6 +113,63 @@ 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_); +} + +StatusOr +EnvironmentsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr EnvironmentsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status EnvironmentsLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..c2311c4b90923 100644 --- a/google/cloud/dialogflow_es/internal/environments_logging_decorator.h +++ b/google/cloud/dialogflow_es/internal/environments_logging_decorator.h @@ -69,6 +69,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..4ef5ba01da821 100644 --- a/google/cloud/dialogflow_es/internal/environments_metadata_decorator.cc +++ b/google/cloud/dialogflow_es/internal/environments_metadata_decorator.cc @@ -99,6 +99,48 @@ 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); +} + +StatusOr +EnvironmentsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr EnvironmentsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status EnvironmentsMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..c6dad4613df88 100644 --- a/google/cloud/dialogflow_es/internal/environments_metadata_decorator.h +++ b/google/cloud/dialogflow_es/internal/environments_metadata_decorator.h @@ -69,6 +69,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..c01f4d3e37be0 100644 --- a/google/cloud/dialogflow_es/internal/environments_stub.cc +++ b/google/cloud/dialogflow_es/internal/environments_stub.cc @@ -102,6 +102,64 @@ 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; +} + +StatusOr +DefaultEnvironmentsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultEnvironmentsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultEnvironmentsStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..32bdc10b6c32f 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,27 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultEnvironmentsStub : public EnvironmentsStub { @@ -73,8 +96,14 @@ 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 + operations_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListEnvironments(grpc::ClientContext& context, Options const& options, @@ -107,9 +136,33 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..5697432bbd7b9 100644 --- a/google/cloud/dialogflow_es/internal/environments_stub_factory.cc +++ b/google/cloud/dialogflow_es/internal/environments_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,14 @@ std::shared_ptr CreateDefaultEnvironmentsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::Environments::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..6291b4e4d33fe 100644 --- a/google/cloud/dialogflow_es/internal/environments_tracing_connection.cc +++ b/google/cloud/dialogflow_es/internal/environments_tracing_connection.cc @@ -92,6 +92,54 @@ 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)); +} + +StreamRange +EnvironmentsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_es::EnvironmentsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +EnvironmentsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_es::EnvironmentsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status EnvironmentsTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_es::EnvironmentsConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..16477692b18b8 100644 --- a/google/cloud/dialogflow_es/internal/environments_tracing_connection.h +++ b/google/cloud/dialogflow_es/internal/environments_tracing_connection.h @@ -64,6 +64,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..68f7fe39b4c2c 100644 --- a/google/cloud/dialogflow_es/internal/environments_tracing_stub.cc +++ b/google/cloud/dialogflow_es/internal/environments_tracing_stub.cc @@ -104,6 +104,64 @@ 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)); +} + +StatusOr +EnvironmentsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Environments", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr EnvironmentsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Environments", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status EnvironmentsTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Environments", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..4a283c83d2c48 100644 --- a/google/cloud/dialogflow_es/internal/environments_tracing_stub.h +++ b/google/cloud/dialogflow_es/internal/environments_tracing_stub.h @@ -69,6 +69,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..973acdea5c2f9 100644 --- a/google/cloud/dialogflow_es/internal/fulfillments_auth_decorator.cc +++ b/google/cloud/dialogflow_es/internal/fulfillments_auth_decorator.cc @@ -49,6 +49,48 @@ 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); +} + +StatusOr +FulfillmentsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr FulfillmentsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status FulfillmentsAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..35bb253d26fe8 100644 --- a/google/cloud/dialogflow_es/internal/fulfillments_auth_decorator.h +++ b/google/cloud/dialogflow_es/internal/fulfillments_auth_decorator.h @@ -48,6 +48,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..83d6b54e061d3 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,114 @@ 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__); +} + +StreamRange +FulfillmentsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +FulfillmentsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status FulfillmentsConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..25e88047064b9 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..4b8568f60b4b2 100644 --- a/google/cloud/dialogflow_es/internal/fulfillments_logging_decorator.cc +++ b/google/cloud/dialogflow_es/internal/fulfillments_logging_decorator.cc @@ -61,6 +61,63 @@ 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_); +} + +StatusOr +FulfillmentsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr FulfillmentsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status FulfillmentsLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..e8c0e5948a5c1 100644 --- a/google/cloud/dialogflow_es/internal/fulfillments_logging_decorator.h +++ b/google/cloud/dialogflow_es/internal/fulfillments_logging_decorator.h @@ -48,6 +48,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..22e4a27f1de05 100644 --- a/google/cloud/dialogflow_es/internal/fulfillments_metadata_decorator.cc +++ b/google/cloud/dialogflow_es/internal/fulfillments_metadata_decorator.cc @@ -63,6 +63,48 @@ 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); +} + +StatusOr +FulfillmentsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr FulfillmentsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status FulfillmentsMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..939310378cbf7 100644 --- a/google/cloud/dialogflow_es/internal/fulfillments_metadata_decorator.h +++ b/google/cloud/dialogflow_es/internal/fulfillments_metadata_decorator.h @@ -48,6 +48,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..4f9ec79825ee9 100644 --- a/google/cloud/dialogflow_es/internal/fulfillments_stub.cc +++ b/google/cloud/dialogflow_es/internal/fulfillments_stub.cc @@ -54,6 +54,64 @@ 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; +} + +StatusOr +DefaultFulfillmentsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultFulfillmentsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultFulfillmentsStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..98a3fd3619b0f 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,27 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultFulfillmentsStub : public FulfillmentsStub { @@ -51,8 +74,14 @@ 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 + operations_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr GetFulfillment( grpc::ClientContext& context, Options const& options, @@ -64,9 +93,33 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..28937e87773c8 100644 --- a/google/cloud/dialogflow_es/internal/fulfillments_stub_factory.cc +++ b/google/cloud/dialogflow_es/internal/fulfillments_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,14 @@ std::shared_ptr CreateDefaultFulfillmentsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::Fulfillments::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..3641d3ab3c3cd 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,54 @@ 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)); +} + +StreamRange +FulfillmentsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_es::FulfillmentsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +FulfillmentsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_es::FulfillmentsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status FulfillmentsTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_es::FulfillmentsConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..5869d851822db 100644 --- a/google/cloud/dialogflow_es/internal/fulfillments_tracing_connection.h +++ b/google/cloud/dialogflow_es/internal/fulfillments_tracing_connection.h @@ -48,6 +48,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..c2e87d582c952 100644 --- a/google/cloud/dialogflow_es/internal/fulfillments_tracing_stub.cc +++ b/google/cloud/dialogflow_es/internal/fulfillments_tracing_stub.cc @@ -56,6 +56,64 @@ 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)); +} + +StatusOr +FulfillmentsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Fulfillments", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr FulfillmentsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Fulfillments", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status FulfillmentsTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Fulfillments", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..ba698cd5887f4 100644 --- a/google/cloud/dialogflow_es/internal/fulfillments_tracing_stub.h +++ b/google/cloud/dialogflow_es/internal/fulfillments_tracing_stub.h @@ -48,6 +48,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..0af9d2c103958 100644 --- a/google/cloud/dialogflow_es/internal/intents_auth_decorator.cc +++ b/google/cloud/dialogflow_es/internal/intents_auth_decorator.cc @@ -128,6 +128,48 @@ 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); +} + +StatusOr +IntentsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr IntentsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status IntentsAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..d2442a656e49f 100644 --- a/google/cloud/dialogflow_es/internal/intents_auth_decorator.h +++ b/google/cloud/dialogflow_es/internal/intents_auth_decorator.h @@ -86,6 +86,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..a45f331b25f17 100644 --- a/google/cloud/dialogflow_es/internal/intents_connection_impl.cc +++ b/google/cloud/dialogflow_es/internal/intents_connection_impl.cc @@ -337,6 +337,112 @@ 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__); +} + +StreamRange +IntentsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr IntentsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status IntentsConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..c1e9033b3d0c2 100644 --- a/google/cloud/dialogflow_es/internal/intents_connection_impl.h +++ b/google/cloud/dialogflow_es/internal/intents_connection_impl.h @@ -93,6 +93,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..cfa978149ba31 100644 --- a/google/cloud/dialogflow_es/internal/intents_logging_decorator.cc +++ b/google/cloud/dialogflow_es/internal/intents_logging_decorator.cc @@ -156,6 +156,63 @@ 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_); +} + +StatusOr +IntentsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr IntentsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status IntentsLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..b84600c33876d 100644 --- a/google/cloud/dialogflow_es/internal/intents_logging_decorator.h +++ b/google/cloud/dialogflow_es/internal/intents_logging_decorator.h @@ -86,6 +86,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..a632500b1ef25 100644 --- a/google/cloud/dialogflow_es/internal/intents_metadata_decorator.cc +++ b/google/cloud/dialogflow_es/internal/intents_metadata_decorator.cc @@ -126,6 +126,48 @@ 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); +} + +StatusOr +IntentsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr IntentsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status IntentsMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..a0b83da70e180 100644 --- a/google/cloud/dialogflow_es/internal/intents_metadata_decorator.h +++ b/google/cloud/dialogflow_es/internal/intents_metadata_decorator.h @@ -86,6 +86,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..69635d1bf1658 100644 --- a/google/cloud/dialogflow_es/internal/intents_stub.cc +++ b/google/cloud/dialogflow_es/internal/intents_stub.cc @@ -149,6 +149,63 @@ 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; +} + +StatusOr +DefaultIntentsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultIntentsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultIntentsStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..9ffb8226d020d 100644 --- a/google/cloud/dialogflow_es/internal/intents_stub.h +++ b/google/cloud/dialogflow_es/internal/intents_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -86,6 +87,27 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -104,9 +126,16 @@ class DefaultIntentsStub : public IntentsStub { DefaultIntentsStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListIntents( grpc::ClientContext& context, Options const& options, @@ -155,6 +184,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -170,6 +219,10 @@ class DefaultIntentsStub : public IntentsStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..673f5ee890c11 100644 --- a/google/cloud/dialogflow_es/internal/intents_stub_factory.cc +++ b/google/cloud/dialogflow_es/internal/intents_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 CreateDefaultIntentsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::Intents::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..64549db776ed6 100644 --- a/google/cloud/dialogflow_es/internal/intents_tracing_connection.cc +++ b/google/cloud/dialogflow_es/internal/intents_tracing_connection.cc @@ -140,6 +140,53 @@ 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)); +} + +StreamRange +IntentsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_es::IntentsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr IntentsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_es::IntentsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status IntentsTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_es::IntentsConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..105ad30b9531f 100644 --- a/google/cloud/dialogflow_es/internal/intents_tracing_connection.h +++ b/google/cloud/dialogflow_es/internal/intents_tracing_connection.h @@ -81,6 +81,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..4fb9e6900e691 100644 --- a/google/cloud/dialogflow_es/internal/intents_tracing_stub.cc +++ b/google/cloud/dialogflow_es/internal/intents_tracing_stub.cc @@ -141,6 +141,63 @@ 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)); +} + +StatusOr +IntentsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Intents", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr IntentsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Intents", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status IntentsTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Intents", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..9bcca67edc1d8 100644 --- a/google/cloud/dialogflow_es/internal/intents_tracing_stub.h +++ b/google/cloud/dialogflow_es/internal/intents_tracing_stub.h @@ -85,6 +85,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..0ed5f8fd9bd15 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,48 @@ 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); +} + +StatusOr +KnowledgeBasesAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr KnowledgeBasesAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status KnowledgeBasesAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..888e50a318238 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..2c9406554a323 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,114 @@ 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__); +} + +StreamRange +KnowledgeBasesConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +KnowledgeBasesConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status KnowledgeBasesConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..552c381c4c943 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..5132d91036f2d 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,63 @@ 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_); +} + +StatusOr +KnowledgeBasesLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr KnowledgeBasesLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status KnowledgeBasesLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..f1f961adfac80 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..eba56e2ac0f9e 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,48 @@ 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); +} + +StatusOr +KnowledgeBasesMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr KnowledgeBasesMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status KnowledgeBasesMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..c53fa6dee7c8a 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..214805c605279 100644 --- a/google/cloud/dialogflow_es/internal/knowledge_bases_stub.cc +++ b/google/cloud/dialogflow_es/internal/knowledge_bases_stub.cc @@ -89,6 +89,65 @@ 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; +} + +StatusOr +DefaultKnowledgeBasesStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultKnowledgeBasesStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultKnowledgeBasesStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..4581fd452a0f2 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,27 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultKnowledgeBasesStub : public KnowledgeBasesStub { @@ -69,8 +92,14 @@ 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 + operations_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListKnowledgeBases( @@ -98,9 +127,33 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..f3343f081f766 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,8 +46,14 @@ std::shared_ptr CreateDefaultKnowledgeBasesStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::KnowledgeBases::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..e54a3e978e39a 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,54 @@ 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)); +} + +StreamRange +KnowledgeBasesTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_es::KnowledgeBasesConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +KnowledgeBasesTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_es::KnowledgeBasesConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status KnowledgeBasesTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_es::KnowledgeBasesConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..31fdc8108611b 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..bb2ff686c9f1c 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,65 @@ 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)); +} + +StatusOr +KnowledgeBasesTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.v2.KnowledgeBases", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +KnowledgeBasesTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.v2.KnowledgeBases", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status KnowledgeBasesTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.v2.KnowledgeBases", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..be8598e83ca3a 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..ae14125c9717f 100644 --- a/google/cloud/dialogflow_es/internal/participants_auth_decorator.cc +++ b/google/cloud/dialogflow_es/internal/participants_auth_decorator.cc @@ -133,6 +133,48 @@ 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); +} + +StatusOr +ParticipantsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr ParticipantsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status ParticipantsAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..2db3ed9ce02e7 100644 --- a/google/cloud/dialogflow_es/internal/participants_auth_decorator.h +++ b/google/cloud/dialogflow_es/internal/participants_auth_decorator.h @@ -94,6 +94,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..e6faffcfacd40 100644 --- a/google/cloud/dialogflow_es/internal/participants_connection_impl.cc +++ b/google/cloud/dialogflow_es/internal/participants_connection_impl.cc @@ -223,6 +223,114 @@ 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__); +} + +StreamRange +ParticipantsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ParticipantsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ParticipantsConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..5992cf07d5ecf 100644 --- a/google/cloud/dialogflow_es/internal/participants_connection_impl.h +++ b/google/cloud/dialogflow_es/internal/participants_connection_impl.h @@ -93,6 +93,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..e9a4ff83fb719 100644 --- a/google/cloud/dialogflow_es/internal/participants_logging_decorator.cc +++ b/google/cloud/dialogflow_es/internal/participants_logging_decorator.cc @@ -179,6 +179,63 @@ 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_); +} + +StatusOr +ParticipantsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ParticipantsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ParticipantsLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..e5e2038fa35b0 100644 --- a/google/cloud/dialogflow_es/internal/participants_logging_decorator.h +++ b/google/cloud/dialogflow_es/internal/participants_logging_decorator.h @@ -94,6 +94,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..3c85881422804 100644 --- a/google/cloud/dialogflow_es/internal/participants_metadata_decorator.cc +++ b/google/cloud/dialogflow_es/internal/participants_metadata_decorator.cc @@ -140,6 +140,48 @@ 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); +} + +StatusOr +ParticipantsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr ParticipantsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status ParticipantsMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..6550b502f86d5 100644 --- a/google/cloud/dialogflow_es/internal/participants_metadata_decorator.h +++ b/google/cloud/dialogflow_es/internal/participants_metadata_decorator.h @@ -94,6 +94,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..3ee8c6fda21a1 100644 --- a/google/cloud/dialogflow_es/internal/participants_stub.cc +++ b/google/cloud/dialogflow_es/internal/participants_stub.cc @@ -157,6 +157,64 @@ 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; +} + +StatusOr +DefaultParticipantsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultParticipantsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultParticipantsStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..a3efb4ea23804 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,27 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultParticipantsStub : public ParticipantsStub { @@ -101,8 +124,14 @@ 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 + operations_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr CreateParticipant( grpc::ClientContext& context, Options const& options, @@ -160,9 +189,33 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..8e11801eee331 100644 --- a/google/cloud/dialogflow_es/internal/participants_stub_factory.cc +++ b/google/cloud/dialogflow_es/internal/participants_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,14 @@ std::shared_ptr CreateDefaultParticipantsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::Participants::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..728220911761d 100644 --- a/google/cloud/dialogflow_es/internal/participants_tracing_connection.cc +++ b/google/cloud/dialogflow_es/internal/participants_tracing_connection.cc @@ -125,6 +125,54 @@ 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)); +} + +StreamRange +ParticipantsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_es::ParticipantsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ParticipantsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_es::ParticipantsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status ParticipantsTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_es::ParticipantsConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..236ee7f7bb93f 100644 --- a/google/cloud/dialogflow_es/internal/participants_tracing_connection.h +++ b/google/cloud/dialogflow_es/internal/participants_tracing_connection.h @@ -83,6 +83,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..1f6ff0d466454 100644 --- a/google/cloud/dialogflow_es/internal/participants_tracing_stub.cc +++ b/google/cloud/dialogflow_es/internal/participants_tracing_stub.cc @@ -161,6 +161,64 @@ 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)); +} + +StatusOr +ParticipantsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Participants", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr ParticipantsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Participants", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status ParticipantsTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Participants", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..234cc47f9b3d1 100644 --- a/google/cloud/dialogflow_es/internal/participants_tracing_stub.h +++ b/google/cloud/dialogflow_es/internal/participants_tracing_stub.h @@ -94,6 +94,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..4f88141007125 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,48 @@ 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); +} + +StatusOr +SessionEntityTypesAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr SessionEntityTypesAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status SessionEntityTypesAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..fbfeb8640c151 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..38b41a204570d 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,114 @@ 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__); +} + +StreamRange +SessionEntityTypesConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +SessionEntityTypesConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status SessionEntityTypesConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..7b8f720d23ea9 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..505061365240b 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,65 @@ 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_); +} + +StatusOr +SessionEntityTypesLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +SessionEntityTypesLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status SessionEntityTypesLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..c1c7871ea6d23 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..f01fa8c8d131c 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,50 @@ 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); +} + +StatusOr +SessionEntityTypesMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +SessionEntityTypesMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status SessionEntityTypesMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..654b451209b53 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..cbab06dba02e0 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,65 @@ 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; +} + +StatusOr +DefaultSessionEntityTypesStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultSessionEntityTypesStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultSessionEntityTypesStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..7c73d34c1186d 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,27 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultSessionEntityTypesStub : public SessionEntityTypesStub { @@ -71,8 +94,14 @@ 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 + operations_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListSessionEntityTypes( @@ -103,10 +132,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr< google::cloud::dialogflow::v2::SessionEntityTypes::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..937b169e71910 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,14 @@ std::shared_ptr CreateDefaultSessionEntityTypesStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::SessionEntityTypes::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..c67408487b7c6 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,54 @@ 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)); +} + +StreamRange +SessionEntityTypesTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_es::SessionEntityTypesConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +SessionEntityTypesTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_es::SessionEntityTypesConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status SessionEntityTypesTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_es::SessionEntityTypesConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..f48041dba7723 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..1628fc9d17afc 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,65 @@ 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)); +} + +StatusOr +SessionEntityTypesTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.v2.SessionEntityTypes", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +SessionEntityTypesTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.v2.SessionEntityTypes", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status SessionEntityTypesTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.v2.SessionEntityTypes", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..5399cd0010daf 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..fde13dcac5733 100644 --- a/google/cloud/dialogflow_es/internal/sessions_auth_decorator.cc +++ b/google/cloud/dialogflow_es/internal/sessions_auth_decorator.cc @@ -60,6 +60,48 @@ 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); +} + +StatusOr +SessionsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr SessionsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status SessionsAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..5640fed848288 100644 --- a/google/cloud/dialogflow_es/internal/sessions_auth_decorator.h +++ b/google/cloud/dialogflow_es/internal/sessions_auth_decorator.h @@ -51,6 +51,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..8aa03dc649ae2 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,112 @@ 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__); +} + +StreamRange +SessionsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr SessionsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status SessionsConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..95b00402ea130 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..7ff27c2052d9e 100644 --- a/google/cloud/dialogflow_es/internal/sessions_logging_decorator.cc +++ b/google/cloud/dialogflow_es/internal/sessions_logging_decorator.cc @@ -74,6 +74,63 @@ 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_); +} + +StatusOr +SessionsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr SessionsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status SessionsLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..1234454d4dd95 100644 --- a/google/cloud/dialogflow_es/internal/sessions_logging_decorator.h +++ b/google/cloud/dialogflow_es/internal/sessions_logging_decorator.h @@ -51,6 +51,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..2a652b601a431 100644 --- a/google/cloud/dialogflow_es/internal/sessions_metadata_decorator.cc +++ b/google/cloud/dialogflow_es/internal/sessions_metadata_decorator.cc @@ -65,6 +65,48 @@ 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); +} + +StatusOr +SessionsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr SessionsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status SessionsMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..ddaa4f045eef7 100644 --- a/google/cloud/dialogflow_es/internal/sessions_metadata_decorator.h +++ b/google/cloud/dialogflow_es/internal/sessions_metadata_decorator.h @@ -51,6 +51,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..98506692d7848 100644 --- a/google/cloud/dialogflow_es/internal/sessions_stub.cc +++ b/google/cloud/dialogflow_es/internal/sessions_stub.cc @@ -59,6 +59,63 @@ 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; +} + +StatusOr +DefaultSessionsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultSessionsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultSessionsStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..a31887e2ac812 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,41 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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 + operations_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr DetectIntent( grpc::ClientContext& context, Options const& options, @@ -71,9 +100,33 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..9f9f41adf1073 100644 --- a/google/cloud/dialogflow_es/internal/sessions_stub_factory.cc +++ b/google/cloud/dialogflow_es/internal/sessions_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 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_operations_stub = + google::longrunning::Operations::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_operations_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..cdd034ce46a73 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,54 @@ 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)); +} + +StreamRange +SessionsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_es::SessionsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +SessionsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_es::SessionsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status SessionsTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_es::SessionsConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..9e709e59ecd9d 100644 --- a/google/cloud/dialogflow_es/internal/sessions_tracing_connection.h +++ b/google/cloud/dialogflow_es/internal/sessions_tracing_connection.h @@ -48,6 +48,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..2382ab17231f4 100644 --- a/google/cloud/dialogflow_es/internal/sessions_tracing_stub.cc +++ b/google/cloud/dialogflow_es/internal/sessions_tracing_stub.cc @@ -62,6 +62,63 @@ 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)); +} + +StatusOr +SessionsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Sessions", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr SessionsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Sessions", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status SessionsTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Sessions", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..2373cbdaa9477 100644 --- a/google/cloud/dialogflow_es/internal/sessions_tracing_stub.h +++ b/google/cloud/dialogflow_es/internal/sessions_tracing_stub.h @@ -51,6 +51,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..886bd1c6f07a3 100644 --- a/google/cloud/dialogflow_es/internal/versions_auth_decorator.cc +++ b/google/cloud/dialogflow_es/internal/versions_auth_decorator.cc @@ -72,6 +72,48 @@ 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); +} + +StatusOr +VersionsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr VersionsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status VersionsAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..54857f41bc6aa 100644 --- a/google/cloud/dialogflow_es/internal/versions_auth_decorator.h +++ b/google/cloud/dialogflow_es/internal/versions_auth_decorator.h @@ -62,6 +62,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..4976ff18be2a7 100644 --- a/google/cloud/dialogflow_es/internal/versions_connection_impl.cc +++ b/google/cloud/dialogflow_es/internal/versions_connection_impl.cc @@ -150,6 +150,112 @@ 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__); +} + +StreamRange +VersionsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr VersionsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status VersionsConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..a53f0feaac12e 100644 --- a/google/cloud/dialogflow_es/internal/versions_connection_impl.h +++ b/google/cloud/dialogflow_es/internal/versions_connection_impl.h @@ -66,6 +66,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..223869f10aaef 100644 --- a/google/cloud/dialogflow_es/internal/versions_logging_decorator.cc +++ b/google/cloud/dialogflow_es/internal/versions_logging_decorator.cc @@ -95,6 +95,63 @@ 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_); +} + +StatusOr +VersionsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr VersionsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status VersionsLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..63445f4e7516c 100644 --- a/google/cloud/dialogflow_es/internal/versions_logging_decorator.h +++ b/google/cloud/dialogflow_es/internal/versions_logging_decorator.h @@ -62,6 +62,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..caefaf1313e08 100644 --- a/google/cloud/dialogflow_es/internal/versions_metadata_decorator.cc +++ b/google/cloud/dialogflow_es/internal/versions_metadata_decorator.cc @@ -88,6 +88,48 @@ 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); +} + +StatusOr +VersionsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr VersionsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status VersionsMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..d79bef069e196 100644 --- a/google/cloud/dialogflow_es/internal/versions_metadata_decorator.h +++ b/google/cloud/dialogflow_es/internal/versions_metadata_decorator.h @@ -62,6 +62,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..737849e7469e0 100644 --- a/google/cloud/dialogflow_es/internal/versions_stub.cc +++ b/google/cloud/dialogflow_es/internal/versions_stub.cc @@ -89,6 +89,63 @@ 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; +} + +StatusOr +DefaultVersionsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultVersionsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultVersionsStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..f292d03d777f4 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,41 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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 + operations_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListVersions( grpc::ClientContext& context, Options const& options, @@ -88,9 +117,33 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..5a35f880b7f75 100644 --- a/google/cloud/dialogflow_es/internal/versions_stub_factory.cc +++ b/google/cloud/dialogflow_es/internal/versions_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 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_operations_stub = + google::longrunning::Operations::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_operations_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..74f76fc5aece3 100644 --- a/google/cloud/dialogflow_es/internal/versions_tracing_connection.cc +++ b/google/cloud/dialogflow_es/internal/versions_tracing_connection.cc @@ -79,6 +79,54 @@ 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)); +} + +StreamRange +VersionsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_es::VersionsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +VersionsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_es::VersionsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status VersionsTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_es::VersionsConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..9add177d8d782 100644 --- a/google/cloud/dialogflow_es/internal/versions_tracing_connection.h +++ b/google/cloud/dialogflow_es/internal/versions_tracing_connection.h @@ -57,6 +57,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..354012cf4225e 100644 --- a/google/cloud/dialogflow_es/internal/versions_tracing_stub.cc +++ b/google/cloud/dialogflow_es/internal/versions_tracing_stub.cc @@ -90,6 +90,63 @@ 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)); +} + +StatusOr +VersionsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Versions", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr VersionsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Versions", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status VersionsTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Versions", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..329f3539086d6 100644 --- a/google/cloud/dialogflow_es/internal/versions_tracing_stub.h +++ b/google/cloud/dialogflow_es/internal/versions_tracing_stub.h @@ -62,6 +62,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..c0224a1ce5ecc 100644 --- a/google/cloud/dialogflow_es/knowledge_bases_client.cc +++ b/google/cloud/dialogflow_es/knowledge_bases_client.cc @@ -119,6 +119,64 @@ 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); +} + +StreamRange +KnowledgeBasesClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +KnowledgeBasesClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr KnowledgeBasesClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr KnowledgeBasesClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status KnowledgeBasesClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status KnowledgeBasesClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..9489a3771077a 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..0acefd98c8179 100644 --- a/google/cloud/dialogflow_es/knowledge_bases_connection.cc +++ b/google/cloud/dialogflow_es/knowledge_bases_connection.cc @@ -69,6 +69,38 @@ 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"); +} + +StreamRange +KnowledgeBasesConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr KnowledgeBasesConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status KnowledgeBasesConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeKnowledgeBasesConnection( std::string const& location, Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..86b7d9d3e3ae9 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,31 @@ 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; +} + +Idempotency KnowledgeBasesConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency KnowledgeBasesConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency KnowledgeBasesConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..19ee297dad4c4 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -51,6 +53,21 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..8ba947faaa00c 100644 --- a/google/cloud/dialogflow_es/mocks/mock_agents_connection.h +++ b/google/cloud/dialogflow_es/mocks/mock_agents_connection.h @@ -217,6 +217,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..5d3706bcb98eb 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,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..c2139a226e965 100644 --- a/google/cloud/dialogflow_es/mocks/mock_contexts_connection.h +++ b/google/cloud/dialogflow_es/mocks/mock_contexts_connection.h @@ -74,6 +74,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..9b83c725d21ae 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,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..6a64c181dd358 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,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..2a9f3469410a6 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,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..e83f33973b1df 100644 --- a/google/cloud/dialogflow_es/mocks/mock_conversations_connection.h +++ b/google/cloud/dialogflow_es/mocks/mock_conversations_connection.h @@ -101,6 +101,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..2f2325ee4b43b 100644 --- a/google/cloud/dialogflow_es/mocks/mock_documents_connection.h +++ b/google/cloud/dialogflow_es/mocks/mock_documents_connection.h @@ -289,6 +289,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..8cf75cb883693 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,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..2beb85a432ea1 100644 --- a/google/cloud/dialogflow_es/mocks/mock_environments_connection.h +++ b/google/cloud/dialogflow_es/mocks/mock_environments_connection.h @@ -77,6 +77,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..2c7279fb89b15 100644 --- a/google/cloud/dialogflow_es/mocks/mock_fulfillments_connection.h +++ b/google/cloud/dialogflow_es/mocks/mock_fulfillments_connection.h @@ -56,6 +56,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..d2d9491535a33 100644 --- a/google/cloud/dialogflow_es/mocks/mock_intents_connection.h +++ b/google/cloud/dialogflow_es/mocks/mock_intents_connection.h @@ -147,6 +147,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..28221a08ff650 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,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..005f45135d5f5 100644 --- a/google/cloud/dialogflow_es/mocks/mock_participants_connection.h +++ b/google/cloud/dialogflow_es/mocks/mock_participants_connection.h @@ -104,6 +104,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..be784cc1d4275 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,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..7ea72e6c8de48 100644 --- a/google/cloud/dialogflow_es/mocks/mock_sessions_connection.h +++ b/google/cloud/dialogflow_es/mocks/mock_sessions_connection.h @@ -57,6 +57,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..18837273c0feb 100644 --- a/google/cloud/dialogflow_es/mocks/mock_versions_connection.h +++ b/google/cloud/dialogflow_es/mocks/mock_versions_connection.h @@ -69,6 +69,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..722172dd10fe5 100644 --- a/google/cloud/dialogflow_es/participants_client.cc +++ b/google/cloud/dialogflow_es/participants_client.cc @@ -199,6 +199,62 @@ 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); +} + +StreamRange ParticipantsClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange ParticipantsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr ParticipantsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr ParticipantsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status ParticipantsClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status ParticipantsClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..0195a4debba66 100644 --- a/google/cloud/dialogflow_es/participants_client.h +++ b/google/cloud/dialogflow_es/participants_client.h @@ -701,6 +701,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..e5a52ce66997f 100644 --- a/google/cloud/dialogflow_es/participants_connection.cc +++ b/google/cloud/dialogflow_es/participants_connection.cc @@ -105,6 +105,37 @@ 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"); +} + +StreamRange +ParticipantsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr ParticipantsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ParticipantsConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeParticipantsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..1eab1bb21a686 100644 --- a/google/cloud/dialogflow_es/participants_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_es/participants_connection_idempotency_policy.cc @@ -79,6 +79,31 @@ 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; +} + +Idempotency ParticipantsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ParticipantsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ParticipantsConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..951ebd091422a 100644 --- a/google/cloud/dialogflow_es/participants_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_es/participants_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 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..cc5e4e9df50b2 100644 --- a/google/cloud/dialogflow_es/session_entity_types_client.cc +++ b/google/cloud/dialogflow_es/session_entity_types_client.cc @@ -133,6 +133,66 @@ 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); +} + +StreamRange +SessionEntityTypesClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +SessionEntityTypesClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr SessionEntityTypesClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr SessionEntityTypesClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status SessionEntityTypesClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status SessionEntityTypesClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..4732f1a85e2fb 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..f97fc65474723 100644 --- a/google/cloud/dialogflow_es/session_entity_types_connection.cc +++ b/google/cloud/dialogflow_es/session_entity_types_connection.cc @@ -69,6 +69,39 @@ 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"); +} + +StreamRange +SessionEntityTypesConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +SessionEntityTypesConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status SessionEntityTypesConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSessionEntityTypesConnection( std::string const& location, Options options) { internal::CheckExpectedOptions ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..29fc111d161ef 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,31 @@ 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; +} + +Idempotency SessionEntityTypesConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SessionEntityTypesConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency SessionEntityTypesConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..40f4b88783f8a 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -55,6 +57,21 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..d01e4f20671f5 100644 --- a/google/cloud/dialogflow_es/sessions_client.cc +++ b/google/cloud/dialogflow_es/sessions_client.cc @@ -60,6 +60,60 @@ 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); +} + +StreamRange SessionsClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange SessionsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr SessionsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr SessionsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status SessionsClient::CancelOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status SessionsClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..7c18d6b97565a 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..7afdcdc5e4004 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,36 @@ 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"); +} + +StreamRange SessionsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr SessionsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status SessionsConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSessionsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions #include @@ -188,6 +189,21 @@ 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..4bbc3b1caa11e 100644 --- a/google/cloud/dialogflow_es/sessions_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_es/sessions_connection_idempotency_policy.cc @@ -39,6 +39,31 @@ 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; +} + +Idempotency SessionsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SessionsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency SessionsConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..55f650c2d6ca7 100644 --- a/google/cloud/dialogflow_es/sessions_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_es/sessions_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -38,6 +40,21 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..057fb6c8ef1ab 100644 --- a/google/cloud/dialogflow_es/versions_client.cc +++ b/google/cloud/dialogflow_es/versions_client.cc @@ -110,6 +110,60 @@ 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); +} + +StreamRange VersionsClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange VersionsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr VersionsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr VersionsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status VersionsClient::CancelOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status VersionsClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..60e3567693bc1 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,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..2a541dc715591 100644 --- a/google/cloud/dialogflow_es/versions_connection.cc +++ b/google/cloud/dialogflow_es/versions_connection.cc @@ -68,6 +68,36 @@ 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"); +} + +StreamRange VersionsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr VersionsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status VersionsConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeVersionsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..2fc953e8663a0 100644 --- a/google/cloud/dialogflow_es/versions_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_es/versions_connection_idempotency_policy.cc @@ -59,6 +59,31 @@ 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; +} + +Idempotency VersionsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency VersionsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency VersionsConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..3288acda73a9e 100644 --- a/google/cloud/dialogflow_es/versions_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_es/versions_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -50,6 +52,21 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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_client.cc b/google/cloud/discoveryengine/v1/completion_client.cc index 053b20c49a69e..0aaa2e37a8e64 100644 --- a/google/cloud/discoveryengine/v1/completion_client.cc +++ b/google/cloud/discoveryengine/v1/completion_client.cc @@ -152,6 +152,52 @@ CompletionServiceClient::PurgeCompletionSuggestions( return connection_->PurgeCompletionSuggestions(operation); } +StreamRange +CompletionServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +CompletionServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr CompletionServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr CompletionServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status CompletionServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status CompletionServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1 } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/completion_client.h b/google/cloud/discoveryengine/v1/completion_client.h index ace4ebbafaa9c..35c80f4bbea06 100644 --- a/google/cloud/discoveryengine/v1/completion_client.h +++ b/google/cloud/discoveryengine/v1/completion_client.h @@ -420,6 +420,231 @@ class CompletionServiceClient { PurgeCompletionSuggestions(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/discoveryengine/v1/completion_connection.cc b/google/cloud/discoveryengine/v1/completion_connection.cc index f2c209fc5ddde..e0dfa220a27de 100644 --- a/google/cloud/discoveryengine/v1/completion_connection.cc +++ b/google/cloud/discoveryengine/v1/completion_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 @@ -155,6 +156,25 @@ CompletionServiceConnection::PurgeCompletionSuggestions( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +CompletionServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +CompletionServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status CompletionServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeCompletionServiceConnection( Options options) { internal::CheckExpectedOptions #include @@ -249,6 +250,15 @@ class CompletionServiceConnection { virtual future> PurgeCompletionSuggestions(google::longrunning::Operation const& operation); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/discoveryengine/v1/completion_connection_idempotency_policy.cc b/google/cloud/discoveryengine/v1/completion_connection_idempotency_policy.cc index d05119092033b..4b8489e4d2ed4 100644 --- a/google/cloud/discoveryengine/v1/completion_connection_idempotency_policy.cc +++ b/google/cloud/discoveryengine/v1/completion_connection_idempotency_policy.cc @@ -67,6 +67,21 @@ CompletionServiceConnectionIdempotencyPolicy::PurgeCompletionSuggestions( return Idempotency::kNonIdempotent; } +Idempotency CompletionServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency CompletionServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency CompletionServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultCompletionServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/discoveryengine/v1/completion_connection_idempotency_policy.h b/google/cloud/discoveryengine/v1/completion_connection_idempotency_policy.h index 11a072d5767dc..3f34fec1ed967 100644 --- a/google/cloud/discoveryengine/v1/completion_connection_idempotency_policy.h +++ b/google/cloud/discoveryengine/v1/completion_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,15 @@ class CompletionServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency PurgeCompletionSuggestions( google::cloud::discoveryengine::v1:: PurgeCompletionSuggestionsRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/discoveryengine/v1/control_client.cc b/google/cloud/discoveryengine/v1/control_client.cc index 717c022db2470..14b60dd4e3c30 100644 --- a/google/cloud/discoveryengine/v1/control_client.cc +++ b/google/cloud/discoveryengine/v1/control_client.cc @@ -119,6 +119,51 @@ ControlServiceClient::ListControls( return connection_->ListControls(std::move(request)); } +StreamRange +ControlServiceClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +ControlServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr ControlServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr ControlServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status ControlServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status ControlServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1 } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/control_client.h b/google/cloud/discoveryengine/v1/control_client.h index e644019a7bc6b..6a95fcc516298 100644 --- a/google/cloud/discoveryengine/v1/control_client.h +++ b/google/cloud/discoveryengine/v1/control_client.h @@ -434,6 +434,231 @@ class ControlServiceClient { google::cloud::discoveryengine::v1::ListControlsRequest request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/discoveryengine/v1/control_connection.cc b/google/cloud/discoveryengine/v1/control_connection.cc index 911bd2017da03..22cf00fd8a351 100644 --- a/google/cloud/discoveryengine/v1/control_connection.cc +++ b/google/cloud/discoveryengine/v1/control_connection.cc @@ -69,6 +69,24 @@ ControlServiceConnection::ListControls( StreamRange>(); } +StreamRange +ControlServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr ControlServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ControlServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeControlServiceConnection( Options options) { internal::CheckExpectedOptions ListControls( google::cloud::discoveryengine::v1::ListControlsRequest request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/discoveryengine/v1/control_connection_idempotency_policy.cc b/google/cloud/discoveryengine/v1/control_connection_idempotency_policy.cc index bce0b17242df7..4dbc54d0506d9 100644 --- a/google/cloud/discoveryengine/v1/control_connection_idempotency_policy.cc +++ b/google/cloud/discoveryengine/v1/control_connection_idempotency_policy.cc @@ -59,6 +59,21 @@ Idempotency ControlServiceConnectionIdempotencyPolicy::ListControls( return Idempotency::kIdempotent; } +Idempotency ControlServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ControlServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ControlServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultControlServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/discoveryengine/v1/control_connection_idempotency_policy.h b/google/cloud/discoveryengine/v1/control_connection_idempotency_policy.h index 176320d7fe1ac..2b7ca3d82f4e3 100644 --- a/google/cloud/discoveryengine/v1/control_connection_idempotency_policy.h +++ b/google/cloud/discoveryengine/v1/control_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 ControlServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListControls( google::cloud::discoveryengine::v1::ListControlsRequest request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/discoveryengine/v1/conversational_search_client.cc b/google/cloud/discoveryengine/v1/conversational_search_client.cc index e050701ba63a3..145b20544197b 100644 --- a/google/cloud/discoveryengine/v1/conversational_search_client.cc +++ b/google/cloud/discoveryengine/v1/conversational_search_client.cc @@ -257,6 +257,54 @@ ConversationalSearchServiceClient::ListSessions( return connection_->ListSessions(std::move(request)); } +StreamRange +ConversationalSearchServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +ConversationalSearchServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +ConversationalSearchServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +ConversationalSearchServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status ConversationalSearchServiceClient::CancelOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status ConversationalSearchServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1 } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/conversational_search_client.h b/google/cloud/discoveryengine/v1/conversational_search_client.h index 49c90c7ccc417..c57f4a2737035 100644 --- a/google/cloud/discoveryengine/v1/conversational_search_client.h +++ b/google/cloud/discoveryengine/v1/conversational_search_client.h @@ -914,6 +914,231 @@ class ConversationalSearchServiceClient { google::cloud::discoveryengine::v1::ListSessionsRequest request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/discoveryengine/v1/conversational_search_connection.cc b/google/cloud/discoveryengine/v1/conversational_search_connection.cc index f918db4ae16be..abc89d71f91b4 100644 --- a/google/cloud/discoveryengine/v1/conversational_search_connection.cc +++ b/google/cloud/discoveryengine/v1/conversational_search_connection.cc @@ -119,6 +119,25 @@ ConversationalSearchServiceConnection::ListSessions( StreamRange>(); } +StreamRange +ConversationalSearchServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +ConversationalSearchServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ConversationalSearchServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeConversationalSearchServiceConnection(Options options) { internal::CheckExpectedOptions ListSessions( google::cloud::discoveryengine::v1::ListSessionsRequest request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/discoveryengine/v1/conversational_search_connection_idempotency_policy.cc b/google/cloud/discoveryengine/v1/conversational_search_connection_idempotency_policy.cc index 9f0f584e676bd..657f817b371a2 100644 --- a/google/cloud/discoveryengine/v1/conversational_search_connection_idempotency_policy.cc +++ b/google/cloud/discoveryengine/v1/conversational_search_connection_idempotency_policy.cc @@ -110,6 +110,24 @@ ConversationalSearchServiceConnectionIdempotencyPolicy::ListSessions( return Idempotency::kIdempotent; } +Idempotency +ConversationalSearchServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency +ConversationalSearchServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +ConversationalSearchServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultConversationalSearchServiceConnectionIdempotencyPolicy() { return std::make_unique< diff --git a/google/cloud/discoveryengine/v1/conversational_search_connection_idempotency_policy.h b/google/cloud/discoveryengine/v1/conversational_search_connection_idempotency_policy.h index b693c2736b3b7..59d29955967a3 100644 --- a/google/cloud/discoveryengine/v1/conversational_search_connection_idempotency_policy.h +++ b/google/cloud/discoveryengine/v1/conversational_search_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 ConversationalSearchServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListSessions( google::cloud::discoveryengine::v1::ListSessionsRequest request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/discoveryengine/v1/data_store_client.cc b/google/cloud/discoveryengine/v1/data_store_client.cc index 7f95423251b18..c1066ab04a582 100644 --- a/google/cloud/discoveryengine/v1/data_store_client.cc +++ b/google/cloud/discoveryengine/v1/data_store_client.cc @@ -175,6 +175,52 @@ DataStoreServiceClient::UpdateDataStore( return connection_->UpdateDataStore(request); } +StreamRange +DataStoreServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +DataStoreServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr DataStoreServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr DataStoreServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status DataStoreServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status DataStoreServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1 } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/data_store_client.h b/google/cloud/discoveryengine/v1/data_store_client.h index e5cec4fb3c3df..e919446102f72 100644 --- a/google/cloud/discoveryengine/v1/data_store_client.h +++ b/google/cloud/discoveryengine/v1/data_store_client.h @@ -576,6 +576,231 @@ class DataStoreServiceClient { google::cloud::discoveryengine::v1::UpdateDataStoreRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/discoveryengine/v1/data_store_connection.cc b/google/cloud/discoveryengine/v1/data_store_connection.cc index 28a6de6555893..5b2bbf04b2309 100644 --- a/google/cloud/discoveryengine/v1/data_store_connection.cc +++ b/google/cloud/discoveryengine/v1/data_store_connection.cc @@ -106,6 +106,25 @@ DataStoreServiceConnection::UpdateDataStore( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +DataStoreServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +DataStoreServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DataStoreServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDataStoreServiceConnection( Options options) { internal::CheckExpectedOptions ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/discoveryengine/v1/data_store_connection_idempotency_policy.cc b/google/cloud/discoveryengine/v1/data_store_connection_idempotency_policy.cc index c8506b5370aec..0ec819cef992a 100644 --- a/google/cloud/discoveryengine/v1/data_store_connection_idempotency_policy.cc +++ b/google/cloud/discoveryengine/v1/data_store_connection_idempotency_policy.cc @@ -59,6 +59,21 @@ Idempotency DataStoreServiceConnectionIdempotencyPolicy::UpdateDataStore( return Idempotency::kNonIdempotent; } +Idempotency DataStoreServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DataStoreServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DataStoreServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultDataStoreServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/discoveryengine/v1/data_store_connection_idempotency_policy.h b/google/cloud/discoveryengine/v1/data_store_connection_idempotency_policy.h index ea9a8fa5718ec..f51cc65dd0063 100644 --- a/google/cloud/discoveryengine/v1/data_store_connection_idempotency_policy.h +++ b/google/cloud/discoveryengine/v1/data_store_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 DataStoreServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency UpdateDataStore( google::cloud::discoveryengine::v1::UpdateDataStoreRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/discoveryengine/v1/document_client.cc b/google/cloud/discoveryengine/v1/document_client.cc index 32a2b841c8bc1..871ba770e1141 100644 --- a/google/cloud/discoveryengine/v1/document_client.cc +++ b/google/cloud/discoveryengine/v1/document_client.cc @@ -165,6 +165,51 @@ DocumentServiceClient::PurgeDocuments( return connection_->PurgeDocuments(operation); } +StreamRange +DocumentServiceClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +DocumentServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr DocumentServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr DocumentServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status DocumentServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status DocumentServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1 } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/document_client.h b/google/cloud/discoveryengine/v1/document_client.h index 85475707f1993..2f1ec6a27cdc3 100644 --- a/google/cloud/discoveryengine/v1/document_client.h +++ b/google/cloud/discoveryengine/v1/document_client.h @@ -609,6 +609,231 @@ class DocumentServiceClient { PurgeDocuments(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/discoveryengine/v1/document_connection.cc b/google/cloud/discoveryengine/v1/document_connection.cc index 3f80ebfd7355b..aa2adccd07ff3 100644 --- a/google/cloud/discoveryengine/v1/document_connection.cc +++ b/google/cloud/discoveryengine/v1/document_connection.cc @@ -117,6 +117,25 @@ DocumentServiceConnection::PurgeDocuments( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +DocumentServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +DocumentServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DocumentServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDocumentServiceConnection( Options options) { internal::CheckExpectedOptions> PurgeDocuments(google::longrunning::Operation const& operation); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/discoveryengine/v1/document_connection_idempotency_policy.cc b/google/cloud/discoveryengine/v1/document_connection_idempotency_policy.cc index b754f71e7703a..5be02d728ea0c 100644 --- a/google/cloud/discoveryengine/v1/document_connection_idempotency_policy.cc +++ b/google/cloud/discoveryengine/v1/document_connection_idempotency_policy.cc @@ -69,6 +69,21 @@ Idempotency DocumentServiceConnectionIdempotencyPolicy::PurgeDocuments( return Idempotency::kNonIdempotent; } +Idempotency DocumentServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DocumentServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DocumentServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultDocumentServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/discoveryengine/v1/document_connection_idempotency_policy.h b/google/cloud/discoveryengine/v1/document_connection_idempotency_policy.h index ef3149177b65a..b6a12083f8716 100644 --- a/google/cloud/discoveryengine/v1/document_connection_idempotency_policy.h +++ b/google/cloud/discoveryengine/v1/document_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -58,6 +59,15 @@ class DocumentServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency PurgeDocuments( google::cloud::discoveryengine::v1::PurgeDocumentsRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/discoveryengine/v1/engine_client.cc b/google/cloud/discoveryengine/v1/engine_client.cc index d377d43819866..4dc2f16c589a3 100644 --- a/google/cloud/discoveryengine/v1/engine_client.cc +++ b/google/cloud/discoveryengine/v1/engine_client.cc @@ -170,6 +170,49 @@ EngineServiceClient::ListEngines( return connection_->ListEngines(std::move(request)); } +StreamRange EngineServiceClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange EngineServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr EngineServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr EngineServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status EngineServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status EngineServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1 } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/engine_client.h b/google/cloud/discoveryengine/v1/engine_client.h index 5eb79734bc62f..db99d9015f172 100644 --- a/google/cloud/discoveryengine/v1/engine_client.h +++ b/google/cloud/discoveryengine/v1/engine_client.h @@ -547,6 +547,231 @@ class EngineServiceClient { google::cloud::discoveryengine::v1::ListEnginesRequest request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/discoveryengine/v1/engine_connection.cc b/google/cloud/discoveryengine/v1/engine_connection.cc index 26c1004210b78..bb86f913b3c9d 100644 --- a/google/cloud/discoveryengine/v1/engine_connection.cc +++ b/google/cloud/discoveryengine/v1/engine_connection.cc @@ -102,6 +102,24 @@ EngineServiceConnection::ListEngines( StreamRange>(); } +StreamRange +EngineServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr EngineServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status EngineServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeEngineServiceConnection( Options options) { internal::CheckExpectedOptions ListEngines( google::cloud::discoveryengine::v1::ListEnginesRequest request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/discoveryengine/v1/engine_connection_idempotency_policy.cc b/google/cloud/discoveryengine/v1/engine_connection_idempotency_policy.cc index 7343c4b306e81..dc8488946eab2 100644 --- a/google/cloud/discoveryengine/v1/engine_connection_idempotency_policy.cc +++ b/google/cloud/discoveryengine/v1/engine_connection_idempotency_policy.cc @@ -59,6 +59,21 @@ Idempotency EngineServiceConnectionIdempotencyPolicy::ListEngines( return Idempotency::kIdempotent; } +Idempotency EngineServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency EngineServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency EngineServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultEngineServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/discoveryengine/v1/engine_connection_idempotency_policy.h b/google/cloud/discoveryengine/v1/engine_connection_idempotency_policy.h index 3499f805e36cc..18ce8f89ec45b 100644 --- a/google/cloud/discoveryengine/v1/engine_connection_idempotency_policy.h +++ b/google/cloud/discoveryengine/v1/engine_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 EngineServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListEngines( google::cloud::discoveryengine::v1::ListEnginesRequest request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/discoveryengine/v1/grounded_generation_client.cc b/google/cloud/discoveryengine/v1/grounded_generation_client.cc index 22c3065445149..748c34e682749 100644 --- a/google/cloud/discoveryengine/v1/grounded_generation_client.cc +++ b/google/cloud/discoveryengine/v1/grounded_generation_client.cc @@ -41,6 +41,54 @@ GroundedGenerationServiceClient::CheckGrounding( return connection_->CheckGrounding(request); } +StreamRange +GroundedGenerationServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +GroundedGenerationServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +GroundedGenerationServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +GroundedGenerationServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status GroundedGenerationServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status GroundedGenerationServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1 } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/grounded_generation_client.h b/google/cloud/discoveryengine/v1/grounded_generation_client.h index ecb0a4f9881de..9e8caf0b743ec 100644 --- a/google/cloud/discoveryengine/v1/grounded_generation_client.h +++ b/google/cloud/discoveryengine/v1/grounded_generation_client.h @@ -122,6 +122,231 @@ class GroundedGenerationServiceClient { google::cloud::discoveryengine::v1::CheckGroundingRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/discoveryengine/v1/grounded_generation_connection.cc b/google/cloud/discoveryengine/v1/grounded_generation_connection.cc index 898016697972f..37b23e3d6012e 100644 --- a/google/cloud/discoveryengine/v1/grounded_generation_connection.cc +++ b/google/cloud/discoveryengine/v1/grounded_generation_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 @@ -44,6 +45,25 @@ GroundedGenerationServiceConnection::CheckGrounding( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +GroundedGenerationServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +GroundedGenerationServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status GroundedGenerationServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeGroundedGenerationServiceConnection(Options options) { internal::CheckExpectedOptions #include @@ -198,6 +199,15 @@ class GroundedGenerationServiceConnection { virtual StatusOr CheckGrounding( google::cloud::discoveryengine::v1::CheckGroundingRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/discoveryengine/v1/grounded_generation_connection_idempotency_policy.cc b/google/cloud/discoveryengine/v1/grounded_generation_connection_idempotency_policy.cc index 0e54c309db002..a453a91d9972a 100644 --- a/google/cloud/discoveryengine/v1/grounded_generation_connection_idempotency_policy.cc +++ b/google/cloud/discoveryengine/v1/grounded_generation_connection_idempotency_policy.cc @@ -41,6 +41,23 @@ GroundedGenerationServiceConnectionIdempotencyPolicy::CheckGrounding( return Idempotency::kNonIdempotent; } +Idempotency +GroundedGenerationServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency GroundedGenerationServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +GroundedGenerationServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultGroundedGenerationServiceConnectionIdempotencyPolicy() { return std::make_unique< diff --git a/google/cloud/discoveryengine/v1/grounded_generation_connection_idempotency_policy.h b/google/cloud/discoveryengine/v1/grounded_generation_connection_idempotency_policy.h index 6a0131cfe1e65..89d3446108038 100644 --- a/google/cloud/discoveryengine/v1/grounded_generation_connection_idempotency_policy.h +++ b/google/cloud/discoveryengine/v1/grounded_generation_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -39,6 +40,15 @@ class GroundedGenerationServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency CheckGrounding( google::cloud::discoveryengine::v1::CheckGroundingRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/discoveryengine/v1/internal/completion_auth_decorator.cc b/google/cloud/discoveryengine/v1/internal/completion_auth_decorator.cc index f2ff201244e1d..6bf0b7a2b26f4 100644 --- a/google/cloud/discoveryengine/v1/internal/completion_auth_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/completion_auth_decorator.cc @@ -164,6 +164,31 @@ CompletionServiceAuth::PurgeCompletionSuggestions( return child_->PurgeCompletionSuggestions(context, options, request); } +StatusOr +CompletionServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr CompletionServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status CompletionServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + future> CompletionServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/completion_auth_decorator.h b/google/cloud/discoveryengine/v1/internal/completion_auth_decorator.h index b80850a2adf70..b579fff646e2b 100644 --- a/google/cloud/discoveryengine/v1/internal/completion_auth_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/completion_auth_decorator.h @@ -96,6 +96,18 @@ class CompletionServiceAuth : public CompletionServiceStub { google::cloud::discoveryengine::v1:: PurgeCompletionSuggestionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/completion_connection_impl.cc b/google/cloud/discoveryengine/v1/internal/completion_connection_impl.cc index 878ba0aef714f..fed780e410690 100644 --- a/google/cloud/discoveryengine/v1/internal/completion_connection_impl.cc +++ b/google/cloud/discoveryengine/v1/internal/completion_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 @@ -488,6 +489,67 @@ CompletionServiceConnectionImpl::PurgeCompletionSuggestions( polling_policy(*current), __func__); } +StreamRange +CompletionServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +CompletionServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status CompletionServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/completion_connection_impl.h b/google/cloud/discoveryengine/v1/internal/completion_connection_impl.h index a52279fc72ae3..780a784739eba 100644 --- a/google/cloud/discoveryengine/v1/internal/completion_connection_impl.h +++ b/google/cloud/discoveryengine/v1/internal/completion_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 @@ -119,6 +120,15 @@ class CompletionServiceConnectionImpl PurgeCompletionSuggestions( google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/discoveryengine/v1/internal/completion_logging_decorator.cc b/google/cloud/discoveryengine/v1/internal/completion_logging_decorator.cc index adca631878a6f..cbc546d4eea97 100644 --- a/google/cloud/discoveryengine/v1/internal/completion_logging_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/completion_logging_decorator.cc @@ -186,6 +186,40 @@ CompletionServiceLogging::PurgeCompletionSuggestions( context, options, request, __func__, tracing_options_); } +StatusOr +CompletionServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr CompletionServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status CompletionServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> CompletionServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/completion_logging_decorator.h b/google/cloud/discoveryengine/v1/internal/completion_logging_decorator.h index 351833745fc28..3eb930926a316 100644 --- a/google/cloud/discoveryengine/v1/internal/completion_logging_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/completion_logging_decorator.h @@ -96,6 +96,18 @@ class CompletionServiceLogging : public CompletionServiceStub { google::cloud::discoveryengine::v1:: PurgeCompletionSuggestionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/completion_metadata_decorator.cc b/google/cloud/discoveryengine/v1/internal/completion_metadata_decorator.cc index 95c8322581bb3..e4743faf27ade 100644 --- a/google/cloud/discoveryengine/v1/internal/completion_metadata_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/completion_metadata_decorator.cc @@ -146,6 +146,32 @@ CompletionServiceMetadata::PurgeCompletionSuggestions( return child_->PurgeCompletionSuggestions(context, options, request); } +StatusOr +CompletionServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +CompletionServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status CompletionServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + future> CompletionServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/completion_metadata_decorator.h b/google/cloud/discoveryengine/v1/internal/completion_metadata_decorator.h index a1003f6c1b09d..f6c3b30e55abf 100644 --- a/google/cloud/discoveryengine/v1/internal/completion_metadata_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/completion_metadata_decorator.h @@ -97,6 +97,18 @@ class CompletionServiceMetadata : public CompletionServiceStub { google::cloud::discoveryengine::v1:: PurgeCompletionSuggestionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/completion_stub.cc b/google/cloud/discoveryengine/v1/internal/completion_stub.cc index 56f4b6dca7af1..037190a3108b5 100644 --- a/google/cloud/discoveryengine/v1/internal/completion_stub.cc +++ b/google/cloud/discoveryengine/v1/internal/completion_stub.cc @@ -183,6 +183,41 @@ DefaultCompletionServiceStub::PurgeCompletionSuggestions( return response; } +StatusOr +DefaultCompletionServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultCompletionServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultCompletionServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + future> DefaultCompletionServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/completion_stub.h b/google/cloud/discoveryengine/v1/internal/completion_stub.h index a6cd9fd0f813e..5990f3b88ca64 100644 --- a/google/cloud/discoveryengine/v1/internal/completion_stub.h +++ b/google/cloud/discoveryengine/v1/internal/completion_stub.h @@ -97,6 +97,18 @@ class CompletionServiceStub { google::cloud::discoveryengine::v1:: PurgeCompletionSuggestionsRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -116,9 +128,13 @@ class DefaultCompletionServiceStub : public CompletionServiceStub { std::unique_ptr< google::cloud::discoveryengine::v1::CompletionService::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr CompleteQuery(grpc::ClientContext& context, Options const& options, @@ -177,6 +193,18 @@ class DefaultCompletionServiceStub : public CompletionServiceStub { google::cloud::discoveryengine::v1:: PurgeCompletionSuggestionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -193,6 +221,8 @@ class DefaultCompletionServiceStub : public CompletionServiceStub { std::unique_ptr< google::cloud::discoveryengine::v1::CompletionService::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/discoveryengine/v1/internal/completion_stub_factory.cc b/google/cloud/discoveryengine/v1/internal/completion_stub_factory.cc index 05e330eeda4b1..2948333825f87 100644 --- a/google/cloud/discoveryengine/v1/internal/completion_stub_factory.cc +++ b/google/cloud/discoveryengine/v1/internal/completion_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 CreateDefaultCompletionServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::discoveryengine::v1::CompletionService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/discoveryengine/v1/internal/completion_tracing_connection.cc b/google/cloud/discoveryengine/v1/internal/completion_tracing_connection.cc index f043df73a2be4..7fda420a235fa 100644 --- a/google/cloud/discoveryengine/v1/internal/completion_tracing_connection.cc +++ b/google/cloud/discoveryengine/v1/internal/completion_tracing_connection.cc @@ -18,6 +18,7 @@ #include "google/cloud/discoveryengine/v1/internal/completion_tracing_connection.h" #include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" #include #include @@ -190,6 +191,34 @@ CompletionServiceTracingConnection::PurgeCompletionSuggestions( child_->PurgeCompletionSuggestions(operation)); } +StreamRange +CompletionServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::CompletionServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +CompletionServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::CompletionServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status CompletionServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::CompletionServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/discoveryengine/v1/internal/completion_tracing_connection.h b/google/cloud/discoveryengine/v1/internal/completion_tracing_connection.h index 8673e02a0332f..86becac3c7514 100644 --- a/google/cloud/discoveryengine/v1/internal/completion_tracing_connection.h +++ b/google/cloud/discoveryengine/v1/internal/completion_tracing_connection.h @@ -108,6 +108,15 @@ class CompletionServiceTracingConnection PurgeCompletionSuggestions( google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/discoveryengine/v1/internal/completion_tracing_stub.cc b/google/cloud/discoveryengine/v1/internal/completion_tracing_stub.cc index 987f902176ddf..515d3004e538e 100644 --- a/google/cloud/discoveryengine/v1/internal/completion_tracing_stub.cc +++ b/google/cloud/discoveryengine/v1/internal/completion_tracing_stub.cc @@ -172,6 +172,41 @@ CompletionServiceTracingStub::PurgeCompletionSuggestions( child_->PurgeCompletionSuggestions(context, options, request)); } +StatusOr +CompletionServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.CompletionService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +CompletionServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.CompletionService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status CompletionServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.CompletionService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + future> CompletionServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/completion_tracing_stub.h b/google/cloud/discoveryengine/v1/internal/completion_tracing_stub.h index 11d20f523114d..5ab758f63daf2 100644 --- a/google/cloud/discoveryengine/v1/internal/completion_tracing_stub.h +++ b/google/cloud/discoveryengine/v1/internal/completion_tracing_stub.h @@ -96,6 +96,18 @@ class CompletionServiceTracingStub : public CompletionServiceStub { google::cloud::discoveryengine::v1:: PurgeCompletionSuggestionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/control_auth_decorator.cc b/google/cloud/discoveryengine/v1/internal/control_auth_decorator.cc index 9d38178c2f8fb..c2a3e884b39de 100644 --- a/google/cloud/discoveryengine/v1/internal/control_auth_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/control_auth_decorator.cc @@ -75,6 +75,31 @@ ControlServiceAuth::ListControls( return child_->ListControls(context, options, request); } +StatusOr +ControlServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr ControlServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status ControlServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/control_auth_decorator.h b/google/cloud/discoveryengine/v1/internal/control_auth_decorator.h index e36cd8f2ea21b..9ef9cc89beea6 100644 --- a/google/cloud/discoveryengine/v1/internal/control_auth_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/control_auth_decorator.h @@ -63,6 +63,18 @@ class ControlServiceAuth : public ControlServiceStub { google::cloud::discoveryengine::v1::ListControlsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/discoveryengine/v1/internal/control_connection_impl.cc b/google/cloud/discoveryengine/v1/internal/control_connection_impl.cc index f9319ff86b69d..27b3ae6e1e92a 100644 --- a/google/cloud/discoveryengine/v1/internal/control_connection_impl.cc +++ b/google/cloud/discoveryengine/v1/internal/control_connection_impl.cc @@ -156,6 +156,66 @@ ControlServiceConnectionImpl::ListControls( }); } +StreamRange +ControlServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ControlServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ControlServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/control_connection_impl.h b/google/cloud/discoveryengine/v1/internal/control_connection_impl.h index e4ef0a156bc24..e4205c3c2e560 100644 --- a/google/cloud/discoveryengine/v1/internal/control_connection_impl.h +++ b/google/cloud/discoveryengine/v1/internal/control_connection_impl.h @@ -68,6 +68,15 @@ class ControlServiceConnectionImpl StreamRange ListControls( google::cloud::discoveryengine::v1::ListControlsRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/discoveryengine/v1/internal/control_logging_decorator.cc b/google/cloud/discoveryengine/v1/internal/control_logging_decorator.cc index 5894dd3c359d3..655e3ff7eb887 100644 --- a/google/cloud/discoveryengine/v1/internal/control_logging_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/control_logging_decorator.cc @@ -99,6 +99,40 @@ ControlServiceLogging::ListControls( context, options, request, __func__, tracing_options_); } +StatusOr +ControlServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ControlServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ControlServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/control_logging_decorator.h b/google/cloud/discoveryengine/v1/internal/control_logging_decorator.h index 5b45742d00d91..956951a5f64e3 100644 --- a/google/cloud/discoveryengine/v1/internal/control_logging_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/control_logging_decorator.h @@ -63,6 +63,18 @@ class ControlServiceLogging : public ControlServiceStub { google::cloud::discoveryengine::v1::ListControlsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/discoveryengine/v1/internal/control_metadata_decorator.cc b/google/cloud/discoveryengine/v1/internal/control_metadata_decorator.cc index 5b97d1f8f48a5..53d28c78999e7 100644 --- a/google/cloud/discoveryengine/v1/internal/control_metadata_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/control_metadata_decorator.cc @@ -89,6 +89,31 @@ ControlServiceMetadata::ListControls( return child_->ListControls(context, options, request); } +StatusOr +ControlServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr ControlServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status ControlServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + void ControlServiceMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/discoveryengine/v1/internal/control_metadata_decorator.h b/google/cloud/discoveryengine/v1/internal/control_metadata_decorator.h index 7ba688274e90a..b21540d41e45f 100644 --- a/google/cloud/discoveryengine/v1/internal/control_metadata_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/control_metadata_decorator.h @@ -63,6 +63,18 @@ class ControlServiceMetadata : public ControlServiceStub { google::cloud::discoveryengine::v1::ListControlsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/discoveryengine/v1/internal/control_stub.cc b/google/cloud/discoveryengine/v1/internal/control_stub.cc index c93c0da9ae41b..24726010f87c6 100644 --- a/google/cloud/discoveryengine/v1/internal/control_stub.cc +++ b/google/cloud/discoveryengine/v1/internal/control_stub.cc @@ -89,6 +89,41 @@ DefaultControlServiceStub::ListControls( return response; } +StatusOr +DefaultControlServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultControlServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultControlServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/control_stub.h b/google/cloud/discoveryengine/v1/internal/control_stub.h index 6ee04e409abb8..dd1e2c7342023 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 @@ -58,6 +59,18 @@ class ControlServiceStub { ListControls(grpc::ClientContext& context, Options const& options, google::cloud::discoveryengine::v1::ListControlsRequest const& request) = 0; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultControlServiceStub : public ControlServiceStub { @@ -65,8 +78,11 @@ class DefaultControlServiceStub : public ControlServiceStub { explicit DefaultControlServiceStub( std::unique_ptr< google::cloud::discoveryengine::v1::ControlService::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr CreateControl( grpc::ClientContext& context, Options const& options, @@ -93,10 +109,24 @@ class DefaultControlServiceStub : public ControlServiceStub { google::cloud::discoveryengine::v1::ListControlsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr< google::cloud::discoveryengine::v1::ControlService::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/discoveryengine/v1/internal/control_stub_factory.cc b/google/cloud/discoveryengine/v1/internal/control_stub_factory.cc index 6e55d17f01b93..2f2d4329e8c1a 100644 --- a/google/cloud/discoveryengine/v1/internal/control_stub_factory.cc +++ b/google/cloud/discoveryengine/v1/internal/control_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 CreateDefaultControlServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::discoveryengine::v1::ControlService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_stub)); if (auth->RequiresConfigureContext()) { stub = diff --git a/google/cloud/discoveryengine/v1/internal/control_tracing_connection.cc b/google/cloud/discoveryengine/v1/internal/control_tracing_connection.cc index 8190953839b5a..2ff651087b03c 100644 --- a/google/cloud/discoveryengine/v1/internal/control_tracing_connection.cc +++ b/google/cloud/discoveryengine/v1/internal/control_tracing_connection.cc @@ -80,6 +80,34 @@ ControlServiceTracingConnection::ListControls( std::move(sr)); } +StreamRange +ControlServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::ControlServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ControlServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::ControlServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status ControlServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::ControlServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/discoveryengine/v1/internal/control_tracing_connection.h b/google/cloud/discoveryengine/v1/internal/control_tracing_connection.h index fe87edf05179d..dd5a765632857 100644 --- a/google/cloud/discoveryengine/v1/internal/control_tracing_connection.h +++ b/google/cloud/discoveryengine/v1/internal/control_tracing_connection.h @@ -59,6 +59,15 @@ class ControlServiceTracingConnection StreamRange ListControls( google::cloud::discoveryengine::v1::ListControlsRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/discoveryengine/v1/internal/control_tracing_stub.cc b/google/cloud/discoveryengine/v1/internal/control_tracing_stub.cc index 037191eb017b9..2c3390052fa18 100644 --- a/google/cloud/discoveryengine/v1/internal/control_tracing_stub.cc +++ b/google/cloud/discoveryengine/v1/internal/control_tracing_stub.cc @@ -91,6 +91,41 @@ ControlServiceTracingStub::ListControls( child_->ListControls(context, options, request)); } +StatusOr +ControlServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.ControlService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +ControlServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.ControlService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status ControlServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.ControlService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeControlServiceTracingStub( diff --git a/google/cloud/discoveryengine/v1/internal/control_tracing_stub.h b/google/cloud/discoveryengine/v1/internal/control_tracing_stub.h index 6b3d71b451b29..bdf5234864e67 100644 --- a/google/cloud/discoveryengine/v1/internal/control_tracing_stub.h +++ b/google/cloud/discoveryengine/v1/internal/control_tracing_stub.h @@ -63,6 +63,18 @@ class ControlServiceTracingStub : public ControlServiceStub { google::cloud::discoveryengine::v1::ListControlsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/discoveryengine/v1/internal/conversational_search_auth_decorator.cc b/google/cloud/discoveryengine/v1/internal/conversational_search_auth_decorator.cc index 3a6da44fb6452..ccc1582410df6 100644 --- a/google/cloud/discoveryengine/v1/internal/conversational_search_auth_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/conversational_search_auth_decorator.cc @@ -151,6 +151,32 @@ ConversationalSearchServiceAuth::ListSessions( return child_->ListSessions(context, options, request); } +StatusOr +ConversationalSearchServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +ConversationalSearchServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status ConversationalSearchServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/conversational_search_auth_decorator.h b/google/cloud/discoveryengine/v1/internal/conversational_search_auth_decorator.h index 9e98905a2ac9d..557650d4e3481 100644 --- a/google/cloud/discoveryengine/v1/internal/conversational_search_auth_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/conversational_search_auth_decorator.h @@ -105,6 +105,18 @@ class ConversationalSearchServiceAuth : public ConversationalSearchServiceStub { google::cloud::discoveryengine::v1::ListSessionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/discoveryengine/v1/internal/conversational_search_connection_impl.cc b/google/cloud/discoveryengine/v1/internal/conversational_search_connection_impl.cc index 4ace416dd1379..5848128ed68d7 100644 --- a/google/cloud/discoveryengine/v1/internal/conversational_search_connection_impl.cc +++ b/google/cloud/discoveryengine/v1/internal/conversational_search_connection_impl.cc @@ -312,6 +312,67 @@ ConversationalSearchServiceConnectionImpl::ListSessions( }); } +StreamRange +ConversationalSearchServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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< + discoveryengine_v1::ConversationalSearchServiceRetryPolicy>( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ConversationalSearchServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ConversationalSearchServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/conversational_search_connection_impl.h b/google/cloud/discoveryengine/v1/internal/conversational_search_connection_impl.h index 5b45ed1b17ef9..5c578e3e4c466 100644 --- a/google/cloud/discoveryengine/v1/internal/conversational_search_connection_impl.h +++ b/google/cloud/discoveryengine/v1/internal/conversational_search_connection_impl.h @@ -103,6 +103,15 @@ class ConversationalSearchServiceConnectionImpl StreamRange ListSessions( google::cloud::discoveryengine::v1::ListSessionsRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr diff --git a/google/cloud/discoveryengine/v1/internal/conversational_search_logging_decorator.cc b/google/cloud/discoveryengine/v1/internal/conversational_search_logging_decorator.cc index 7385679fb886f..341286eea1efc 100644 --- a/google/cloud/discoveryengine/v1/internal/conversational_search_logging_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/conversational_search_logging_decorator.cc @@ -211,6 +211,41 @@ ConversationalSearchServiceLogging::ListSessions( context, options, request, __func__, tracing_options_); } +StatusOr +ConversationalSearchServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ConversationalSearchServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ConversationalSearchServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/conversational_search_logging_decorator.h b/google/cloud/discoveryengine/v1/internal/conversational_search_logging_decorator.h index 058e0d643e2b2..2793a73690013 100644 --- a/google/cloud/discoveryengine/v1/internal/conversational_search_logging_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/conversational_search_logging_decorator.h @@ -106,6 +106,18 @@ class ConversationalSearchServiceLogging google::cloud::discoveryengine::v1::ListSessionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/discoveryengine/v1/internal/conversational_search_metadata_decorator.cc b/google/cloud/discoveryengine/v1/internal/conversational_search_metadata_decorator.cc index 7069b8bb18e7a..6f21e945e72e5 100644 --- a/google/cloud/discoveryengine/v1/internal/conversational_search_metadata_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/conversational_search_metadata_decorator.cc @@ -167,6 +167,32 @@ ConversationalSearchServiceMetadata::ListSessions( return child_->ListSessions(context, options, request); } +StatusOr +ConversationalSearchServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +ConversationalSearchServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status ConversationalSearchServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + void ConversationalSearchServiceMetadata::SetMetadata( grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/discoveryengine/v1/internal/conversational_search_metadata_decorator.h b/google/cloud/discoveryengine/v1/internal/conversational_search_metadata_decorator.h index 83aea2b7dfa81..9d16cae33bfea 100644 --- a/google/cloud/discoveryengine/v1/internal/conversational_search_metadata_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/conversational_search_metadata_decorator.h @@ -107,6 +107,18 @@ class ConversationalSearchServiceMetadata google::cloud::discoveryengine::v1::ListSessionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/discoveryengine/v1/internal/conversational_search_stub.cc b/google/cloud/discoveryengine/v1/internal/conversational_search_stub.cc index 99f73e96abbd3..1a0b0cd24805f 100644 --- a/google/cloud/discoveryengine/v1/internal/conversational_search_stub.cc +++ b/google/cloud/discoveryengine/v1/internal/conversational_search_stub.cc @@ -189,6 +189,41 @@ DefaultConversationalSearchServiceStub::ListSessions( return response; } +StatusOr +DefaultConversationalSearchServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultConversationalSearchServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultConversationalSearchServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/conversational_search_stub.h b/google/cloud/discoveryengine/v1/internal/conversational_search_stub.h index 60047978787a6..6b9bbc8992ae6 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 @@ -104,6 +105,18 @@ class ConversationalSearchServiceStub { ListSessions(grpc::ClientContext& context, Options const& options, google::cloud::discoveryengine::v1::ListSessionsRequest const& request) = 0; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultConversationalSearchServiceStub @@ -112,8 +125,11 @@ class DefaultConversationalSearchServiceStub explicit DefaultConversationalSearchServiceStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr ConverseConversation( @@ -182,10 +198,24 @@ class DefaultConversationalSearchServiceStub google::cloud::discoveryengine::v1::ListSessionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/discoveryengine/v1/internal/conversational_search_stub_factory.cc b/google/cloud/discoveryengine/v1/internal/conversational_search_stub_factory.cc index 1ccdcf27f6870..9c7cd929071a4 100644 --- a/google/cloud/discoveryengine/v1/internal/conversational_search_stub_factory.cc +++ b/google/cloud/discoveryengine/v1/internal/conversational_search_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 @@ CreateDefaultConversationalSearchServiceStub( auto service_grpc_stub = google::cloud::discoveryengine::v1::ConversationalSearchService::NewStub( channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_operations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/discoveryengine/v1/internal/conversational_search_tracing_connection.cc b/google/cloud/discoveryengine/v1/internal/conversational_search_tracing_connection.cc index d5a912468ac8c..03cd16f69ecf0 100644 --- a/google/cloud/discoveryengine/v1/internal/conversational_search_tracing_connection.cc +++ b/google/cloud/discoveryengine/v1/internal/conversational_search_tracing_connection.cc @@ -171,6 +171,37 @@ ConversationalSearchServiceTracingConnection::ListSessions( std::move(sr)); } +StreamRange +ConversationalSearchServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::ConversationalSearchServiceConnection::" + "ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ConversationalSearchServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::ConversationalSearchServiceConnection::" + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status ConversationalSearchServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::ConversationalSearchServiceConnection::" + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/discoveryengine/v1/internal/conversational_search_tracing_connection.h b/google/cloud/discoveryengine/v1/internal/conversational_search_tracing_connection.h index c4b17055fd094..43931afbcf562 100644 --- a/google/cloud/discoveryengine/v1/internal/conversational_search_tracing_connection.h +++ b/google/cloud/discoveryengine/v1/internal/conversational_search_tracing_connection.h @@ -93,6 +93,15 @@ class ConversationalSearchServiceTracingConnection StreamRange ListSessions( google::cloud::discoveryengine::v1::ListSessionsRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; diff --git a/google/cloud/discoveryengine/v1/internal/conversational_search_tracing_stub.cc b/google/cloud/discoveryengine/v1/internal/conversational_search_tracing_stub.cc index fa89ad5681353..cf0c467693949 100644 --- a/google/cloud/discoveryengine/v1/internal/conversational_search_tracing_stub.cc +++ b/google/cloud/discoveryengine/v1/internal/conversational_search_tracing_stub.cc @@ -204,6 +204,44 @@ ConversationalSearchServiceTracingStub::ListSessions( child_->ListSessions(context, options, request)); } +StatusOr +ConversationalSearchServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.ConversationalSearchService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +ConversationalSearchServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.ConversationalSearchService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status ConversationalSearchServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.ConversationalSearchService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/discoveryengine/v1/internal/conversational_search_tracing_stub.h b/google/cloud/discoveryengine/v1/internal/conversational_search_tracing_stub.h index 5ff2870995fba..01887accada06 100644 --- a/google/cloud/discoveryengine/v1/internal/conversational_search_tracing_stub.h +++ b/google/cloud/discoveryengine/v1/internal/conversational_search_tracing_stub.h @@ -107,6 +107,18 @@ class ConversationalSearchServiceTracingStub google::cloud::discoveryengine::v1::ListSessionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/discoveryengine/v1/internal/data_store_auth_decorator.cc b/google/cloud/discoveryengine/v1/internal/data_store_auth_decorator.cc index 17b065cb35524..ef6350d3b1f89 100644 --- a/google/cloud/discoveryengine/v1/internal/data_store_auth_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/data_store_auth_decorator.cc @@ -114,6 +114,31 @@ DataStoreServiceAuth::UpdateDataStore( return child_->UpdateDataStore(context, options, request); } +StatusOr +DataStoreServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr DataStoreServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status DataStoreServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + future> DataStoreServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/data_store_auth_decorator.h b/google/cloud/discoveryengine/v1/internal/data_store_auth_decorator.h index b0196c5d5aa8b..29a8a9412d476 100644 --- a/google/cloud/discoveryengine/v1/internal/data_store_auth_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/data_store_auth_decorator.h @@ -79,6 +79,18 @@ class DataStoreServiceAuth : public DataStoreServiceStub { google::cloud::discoveryengine::v1::UpdateDataStoreRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/data_store_connection_impl.cc b/google/cloud/discoveryengine/v1/internal/data_store_connection_impl.cc index acb4852f70657..6788397d49625 100644 --- a/google/cloud/discoveryengine/v1/internal/data_store_connection_impl.cc +++ b/google/cloud/discoveryengine/v1/internal/data_store_connection_impl.cc @@ -321,6 +321,66 @@ DataStoreServiceConnectionImpl::UpdateDataStore( *current, request, __func__); } +StreamRange +DataStoreServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DataStoreServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DataStoreServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/data_store_connection_impl.h b/google/cloud/discoveryengine/v1/internal/data_store_connection_impl.h index 5976c0ec1f683..0b37285ea6739 100644 --- a/google/cloud/discoveryengine/v1/internal/data_store_connection_impl.h +++ b/google/cloud/discoveryengine/v1/internal/data_store_connection_impl.h @@ -90,6 +90,15 @@ class DataStoreServiceConnectionImpl google::cloud::discoveryengine::v1::UpdateDataStoreRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/discoveryengine/v1/internal/data_store_logging_decorator.cc b/google/cloud/discoveryengine/v1/internal/data_store_logging_decorator.cc index 44f16a82230d5..82dcff1d19230 100644 --- a/google/cloud/discoveryengine/v1/internal/data_store_logging_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/data_store_logging_decorator.cc @@ -138,6 +138,40 @@ DataStoreServiceLogging::UpdateDataStore( context, options, request, __func__, tracing_options_); } +StatusOr +DataStoreServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DataStoreServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DataStoreServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> DataStoreServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/data_store_logging_decorator.h b/google/cloud/discoveryengine/v1/internal/data_store_logging_decorator.h index 9d78d9f028ad0..e2e5f5097a01a 100644 --- a/google/cloud/discoveryengine/v1/internal/data_store_logging_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/data_store_logging_decorator.h @@ -79,6 +79,18 @@ class DataStoreServiceLogging : public DataStoreServiceStub { google::cloud::discoveryengine::v1::UpdateDataStoreRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/data_store_metadata_decorator.cc b/google/cloud/discoveryengine/v1/internal/data_store_metadata_decorator.cc index a2b17780e8925..d0999c697c84e 100644 --- a/google/cloud/discoveryengine/v1/internal/data_store_metadata_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/data_store_metadata_decorator.cc @@ -114,6 +114,31 @@ DataStoreServiceMetadata::UpdateDataStore( return child_->UpdateDataStore(context, options, request); } +StatusOr +DataStoreServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr DataStoreServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status DataStoreServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + future> DataStoreServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/data_store_metadata_decorator.h b/google/cloud/discoveryengine/v1/internal/data_store_metadata_decorator.h index f74d1fea98f2c..5a57b4d68d59b 100644 --- a/google/cloud/discoveryengine/v1/internal/data_store_metadata_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/data_store_metadata_decorator.h @@ -80,6 +80,18 @@ class DataStoreServiceMetadata : public DataStoreServiceStub { google::cloud::discoveryengine::v1::UpdateDataStoreRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/data_store_stub.cc b/google/cloud/discoveryengine/v1/internal/data_store_stub.cc index 58be6aaa096ba..c62b5c43d07c5 100644 --- a/google/cloud/discoveryengine/v1/internal/data_store_stub.cc +++ b/google/cloud/discoveryengine/v1/internal/data_store_stub.cc @@ -129,6 +129,41 @@ DefaultDataStoreServiceStub::UpdateDataStore( return response; } +StatusOr +DefaultDataStoreServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataStoreServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultDataStoreServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + future> DefaultDataStoreServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/data_store_stub.h b/google/cloud/discoveryengine/v1/internal/data_store_stub.h index cd5bd11102c64..6fb36e5e9b5e5 100644 --- a/google/cloud/discoveryengine/v1/internal/data_store_stub.h +++ b/google/cloud/discoveryengine/v1/internal/data_store_stub.h @@ -79,6 +79,18 @@ class DataStoreServiceStub { google::cloud::discoveryengine::v1::UpdateDataStoreRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -98,9 +110,13 @@ class DefaultDataStoreServiceStub : public DataStoreServiceStub { std::unique_ptr< google::cloud::discoveryengine::v1::DataStoreService::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateDataStore( google::cloud::CompletionQueue& cq, @@ -142,6 +158,18 @@ class DefaultDataStoreServiceStub : public DataStoreServiceStub { google::cloud::discoveryengine::v1::UpdateDataStoreRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -158,6 +186,8 @@ class DefaultDataStoreServiceStub : public DataStoreServiceStub { std::unique_ptr< google::cloud::discoveryengine::v1::DataStoreService::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/discoveryengine/v1/internal/data_store_stub_factory.cc b/google/cloud/discoveryengine/v1/internal/data_store_stub_factory.cc index 3835358ef0012..36bfae60a53a4 100644 --- a/google/cloud/discoveryengine/v1/internal/data_store_stub_factory.cc +++ b/google/cloud/discoveryengine/v1/internal/data_store_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 CreateDefaultDataStoreServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::discoveryengine::v1::DataStoreService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/discoveryengine/v1/internal/data_store_tracing_connection.cc b/google/cloud/discoveryengine/v1/internal/data_store_tracing_connection.cc index 3051bad0edbdb..4a0d06ef0c96d 100644 --- a/google/cloud/discoveryengine/v1/internal/data_store_tracing_connection.cc +++ b/google/cloud/discoveryengine/v1/internal/data_store_tracing_connection.cc @@ -121,6 +121,34 @@ DataStoreServiceTracingConnection::UpdateDataStore( return internal::EndSpan(*span, child_->UpdateDataStore(request)); } +StreamRange +DataStoreServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::DataStoreServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DataStoreServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::DataStoreServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status DataStoreServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::DataStoreServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/discoveryengine/v1/internal/data_store_tracing_connection.h b/google/cloud/discoveryengine/v1/internal/data_store_tracing_connection.h index 34f9e12302db1..bf846f5d6f820 100644 --- a/google/cloud/discoveryengine/v1/internal/data_store_tracing_connection.h +++ b/google/cloud/discoveryengine/v1/internal/data_store_tracing_connection.h @@ -78,6 +78,15 @@ class DataStoreServiceTracingConnection google::cloud::discoveryengine::v1::UpdateDataStoreRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/discoveryengine/v1/internal/data_store_tracing_stub.cc b/google/cloud/discoveryengine/v1/internal/data_store_tracing_stub.cc index 5e2f8f3a783ba..0de2d4d8a7cb9 100644 --- a/google/cloud/discoveryengine/v1/internal/data_store_tracing_stub.cc +++ b/google/cloud/discoveryengine/v1/internal/data_store_tracing_stub.cc @@ -122,6 +122,41 @@ DataStoreServiceTracingStub::UpdateDataStore( child_->UpdateDataStore(context, options, request)); } +StatusOr +DataStoreServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.DataStoreService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +DataStoreServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.DataStoreService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status DataStoreServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.DataStoreService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + future> DataStoreServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/data_store_tracing_stub.h b/google/cloud/discoveryengine/v1/internal/data_store_tracing_stub.h index 0b7e23d9122ee..84684210b514c 100644 --- a/google/cloud/discoveryengine/v1/internal/data_store_tracing_stub.h +++ b/google/cloud/discoveryengine/v1/internal/data_store_tracing_stub.h @@ -79,6 +79,18 @@ class DataStoreServiceTracingStub : public DataStoreServiceStub { google::cloud::discoveryengine::v1::UpdateDataStoreRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/document_auth_decorator.cc b/google/cloud/discoveryengine/v1/internal/document_auth_decorator.cc index dc2b381927a7f..b9eced4fa3637 100644 --- a/google/cloud/discoveryengine/v1/internal/document_auth_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/document_auth_decorator.cc @@ -131,6 +131,31 @@ StatusOr DocumentServiceAuth::PurgeDocuments( return child_->PurgeDocuments(context, options, request); } +StatusOr +DocumentServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr DocumentServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status DocumentServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + future> DocumentServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/document_auth_decorator.h b/google/cloud/discoveryengine/v1/internal/document_auth_decorator.h index 62a1e3e64e3cc..eeecbf2b63acb 100644 --- a/google/cloud/discoveryengine/v1/internal/document_auth_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/document_auth_decorator.h @@ -88,6 +88,18 @@ class DocumentServiceAuth : public DocumentServiceStub { google::cloud::discoveryengine::v1::PurgeDocumentsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/document_connection_impl.cc b/google/cloud/discoveryengine/v1/internal/document_connection_impl.cc index c06d2ce273e2f..832d4ea2d4b9c 100644 --- a/google/cloud/discoveryengine/v1/internal/document_connection_impl.cc +++ b/google/cloud/discoveryengine/v1/internal/document_connection_impl.cc @@ -350,6 +350,66 @@ DocumentServiceConnectionImpl::PurgeDocuments( polling_policy(*current), __func__); } +StreamRange +DocumentServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DocumentServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DocumentServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/document_connection_impl.h b/google/cloud/discoveryengine/v1/internal/document_connection_impl.h index 320247b07dde2..284c6e1e7e2c0 100644 --- a/google/cloud/discoveryengine/v1/internal/document_connection_impl.h +++ b/google/cloud/discoveryengine/v1/internal/document_connection_impl.h @@ -98,6 +98,15 @@ class DocumentServiceConnectionImpl future> PurgeDocuments(google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/discoveryengine/v1/internal/document_logging_decorator.cc b/google/cloud/discoveryengine/v1/internal/document_logging_decorator.cc index 1d82ce4ec6f12..ed788a0e8dfa0 100644 --- a/google/cloud/discoveryengine/v1/internal/document_logging_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/document_logging_decorator.cc @@ -162,6 +162,40 @@ StatusOr DocumentServiceLogging::PurgeDocuments( context, options, request, __func__, tracing_options_); } +StatusOr +DocumentServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DocumentServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DocumentServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> DocumentServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/document_logging_decorator.h b/google/cloud/discoveryengine/v1/internal/document_logging_decorator.h index 103493645feab..74e9d7226ae3b 100644 --- a/google/cloud/discoveryengine/v1/internal/document_logging_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/document_logging_decorator.h @@ -88,6 +88,18 @@ class DocumentServiceLogging : public DocumentServiceStub { google::cloud::discoveryengine::v1::PurgeDocumentsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/document_metadata_decorator.cc b/google/cloud/discoveryengine/v1/internal/document_metadata_decorator.cc index 109e1fc0a696e..a8f11a17efddb 100644 --- a/google/cloud/discoveryengine/v1/internal/document_metadata_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/document_metadata_decorator.cc @@ -131,6 +131,31 @@ DocumentServiceMetadata::PurgeDocuments( return child_->PurgeDocuments(context, options, request); } +StatusOr +DocumentServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr DocumentServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status DocumentServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + future> DocumentServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/document_metadata_decorator.h b/google/cloud/discoveryengine/v1/internal/document_metadata_decorator.h index 29176538ad6f6..32c884f521467 100644 --- a/google/cloud/discoveryengine/v1/internal/document_metadata_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/document_metadata_decorator.h @@ -89,6 +89,18 @@ class DocumentServiceMetadata : public DocumentServiceStub { google::cloud::discoveryengine::v1::PurgeDocumentsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/document_stub.cc b/google/cloud/discoveryengine/v1/internal/document_stub.cc index 9d7461c17fb7d..70b56b14a8abf 100644 --- a/google/cloud/discoveryengine/v1/internal/document_stub.cc +++ b/google/cloud/discoveryengine/v1/internal/document_stub.cc @@ -152,6 +152,41 @@ DefaultDocumentServiceStub::PurgeDocuments( return response; } +StatusOr +DefaultDocumentServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDocumentServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultDocumentServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + future> DefaultDocumentServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/document_stub.h b/google/cloud/discoveryengine/v1/internal/document_stub.h index 3e10e3bec0787..a7590ad62f673 100644 --- a/google/cloud/discoveryengine/v1/internal/document_stub.h +++ b/google/cloud/discoveryengine/v1/internal/document_stub.h @@ -87,6 +87,18 @@ class DocumentServiceStub { google::cloud::discoveryengine::v1::PurgeDocumentsRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -106,9 +118,13 @@ class DefaultDocumentServiceStub : public DocumentServiceStub { std::unique_ptr< google::cloud::discoveryengine::v1::DocumentService::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr GetDocument( grpc::ClientContext& context, Options const& options, @@ -159,6 +175,18 @@ class DefaultDocumentServiceStub : public DocumentServiceStub { google::cloud::discoveryengine::v1::PurgeDocumentsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -175,6 +203,8 @@ class DefaultDocumentServiceStub : public DocumentServiceStub { std::unique_ptr< google::cloud::discoveryengine::v1::DocumentService::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/discoveryengine/v1/internal/document_stub_factory.cc b/google/cloud/discoveryengine/v1/internal/document_stub_factory.cc index 609722b06a098..39f7c5be76d52 100644 --- a/google/cloud/discoveryengine/v1/internal/document_stub_factory.cc +++ b/google/cloud/discoveryengine/v1/internal/document_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 CreateDefaultDocumentServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::discoveryengine::v1::DocumentService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/discoveryengine/v1/internal/document_tracing_connection.cc b/google/cloud/discoveryengine/v1/internal/document_tracing_connection.cc index 05c22b8f9b99a..fd4390cfc1ac4 100644 --- a/google/cloud/discoveryengine/v1/internal/document_tracing_connection.cc +++ b/google/cloud/discoveryengine/v1/internal/document_tracing_connection.cc @@ -138,6 +138,34 @@ DocumentServiceTracingConnection::PurgeDocuments( return internal::EndSpan(std::move(span), child_->PurgeDocuments(operation)); } +StreamRange +DocumentServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::DocumentServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DocumentServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::DocumentServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status DocumentServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::DocumentServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/discoveryengine/v1/internal/document_tracing_connection.h b/google/cloud/discoveryengine/v1/internal/document_tracing_connection.h index c9cf448bce906..ea3ad0f1046b6 100644 --- a/google/cloud/discoveryengine/v1/internal/document_tracing_connection.h +++ b/google/cloud/discoveryengine/v1/internal/document_tracing_connection.h @@ -86,6 +86,15 @@ class DocumentServiceTracingConnection future> PurgeDocuments(google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/discoveryengine/v1/internal/document_tracing_stub.cc b/google/cloud/discoveryengine/v1/internal/document_tracing_stub.cc index 8c8c1f6515c64..82cdb8b5c1c1c 100644 --- a/google/cloud/discoveryengine/v1/internal/document_tracing_stub.cc +++ b/google/cloud/discoveryengine/v1/internal/document_tracing_stub.cc @@ -145,6 +145,41 @@ DocumentServiceTracingStub::PurgeDocuments( child_->PurgeDocuments(context, options, request)); } +StatusOr +DocumentServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.DocumentService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +DocumentServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.DocumentService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status DocumentServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.DocumentService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + future> DocumentServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/document_tracing_stub.h b/google/cloud/discoveryengine/v1/internal/document_tracing_stub.h index fbbe10da816fb..88fb42d2ac8fb 100644 --- a/google/cloud/discoveryengine/v1/internal/document_tracing_stub.h +++ b/google/cloud/discoveryengine/v1/internal/document_tracing_stub.h @@ -88,6 +88,18 @@ class DocumentServiceTracingStub : public DocumentServiceStub { google::cloud::discoveryengine::v1::PurgeDocumentsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/engine_auth_decorator.cc b/google/cloud/discoveryengine/v1/internal/engine_auth_decorator.cc index b5927eaf0b48c..d5cb0b2c30259 100644 --- a/google/cloud/discoveryengine/v1/internal/engine_auth_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/engine_auth_decorator.cc @@ -114,6 +114,31 @@ EngineServiceAuth::ListEngines( return child_->ListEngines(context, options, request); } +StatusOr +EngineServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr EngineServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status EngineServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + future> EngineServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/engine_auth_decorator.h b/google/cloud/discoveryengine/v1/internal/engine_auth_decorator.h index e679d07351ff7..37bea7f19fd56 100644 --- a/google/cloud/discoveryengine/v1/internal/engine_auth_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/engine_auth_decorator.h @@ -78,6 +78,18 @@ class EngineServiceAuth : public EngineServiceStub { google::cloud::discoveryengine::v1::ListEnginesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/engine_connection_impl.cc b/google/cloud/discoveryengine/v1/internal/engine_connection_impl.cc index dd0b387f5a95a..9fb70142bce4a 100644 --- a/google/cloud/discoveryengine/v1/internal/engine_connection_impl.cc +++ b/google/cloud/discoveryengine/v1/internal/engine_connection_impl.cc @@ -319,6 +319,66 @@ EngineServiceConnectionImpl::ListEngines( }); } +StreamRange +EngineServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +EngineServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status EngineServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/engine_connection_impl.h b/google/cloud/discoveryengine/v1/internal/engine_connection_impl.h index 3ce0c78578244..50011826db5dd 100644 --- a/google/cloud/discoveryengine/v1/internal/engine_connection_impl.h +++ b/google/cloud/discoveryengine/v1/internal/engine_connection_impl.h @@ -87,6 +87,15 @@ class EngineServiceConnectionImpl StreamRange ListEngines( google::cloud::discoveryengine::v1::ListEnginesRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/discoveryengine/v1/internal/engine_logging_decorator.cc b/google/cloud/discoveryengine/v1/internal/engine_logging_decorator.cc index e2f9ca6c442e6..4dae430faf2eb 100644 --- a/google/cloud/discoveryengine/v1/internal/engine_logging_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/engine_logging_decorator.cc @@ -136,6 +136,40 @@ EngineServiceLogging::ListEngines( context, options, request, __func__, tracing_options_); } +StatusOr +EngineServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr EngineServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status EngineServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> EngineServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/engine_logging_decorator.h b/google/cloud/discoveryengine/v1/internal/engine_logging_decorator.h index 46c724754ebf9..5b06c27bad3d6 100644 --- a/google/cloud/discoveryengine/v1/internal/engine_logging_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/engine_logging_decorator.h @@ -78,6 +78,18 @@ class EngineServiceLogging : public EngineServiceStub { google::cloud::discoveryengine::v1::ListEnginesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/engine_metadata_decorator.cc b/google/cloud/discoveryengine/v1/internal/engine_metadata_decorator.cc index 4cbf962feef1b..7887e8021a255 100644 --- a/google/cloud/discoveryengine/v1/internal/engine_metadata_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/engine_metadata_decorator.cc @@ -112,6 +112,31 @@ EngineServiceMetadata::ListEngines( return child_->ListEngines(context, options, request); } +StatusOr +EngineServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr EngineServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status EngineServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + future> EngineServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/engine_metadata_decorator.h b/google/cloud/discoveryengine/v1/internal/engine_metadata_decorator.h index 8328b19fff59a..10c0d20333322 100644 --- a/google/cloud/discoveryengine/v1/internal/engine_metadata_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/engine_metadata_decorator.h @@ -78,6 +78,18 @@ class EngineServiceMetadata : public EngineServiceStub { google::cloud::discoveryengine::v1::ListEnginesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/engine_stub.cc b/google/cloud/discoveryengine/v1/internal/engine_stub.cc index 2c570e6b83643..dd098fa2df838 100644 --- a/google/cloud/discoveryengine/v1/internal/engine_stub.cc +++ b/google/cloud/discoveryengine/v1/internal/engine_stub.cc @@ -127,6 +127,40 @@ DefaultEngineServiceStub::ListEngines( return response; } +StatusOr +DefaultEngineServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultEngineServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultEngineServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + future> DefaultEngineServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/engine_stub.h b/google/cloud/discoveryengine/v1/internal/engine_stub.h index 0a3ffac79cf70..85dd8a860f62e 100644 --- a/google/cloud/discoveryengine/v1/internal/engine_stub.h +++ b/google/cloud/discoveryengine/v1/internal/engine_stub.h @@ -76,6 +76,18 @@ class EngineServiceStub { google::cloud::discoveryengine::v1::ListEnginesRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -95,9 +107,13 @@ class DefaultEngineServiceStub : public EngineServiceStub { std::unique_ptr< google::cloud::discoveryengine::v1::EngineService::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateEngine( google::cloud::CompletionQueue& cq, @@ -138,6 +154,18 @@ class DefaultEngineServiceStub : public EngineServiceStub { google::cloud::discoveryengine::v1::ListEnginesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -154,6 +182,8 @@ class DefaultEngineServiceStub : public EngineServiceStub { std::unique_ptr< google::cloud::discoveryengine::v1::EngineService::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/discoveryengine/v1/internal/engine_stub_factory.cc b/google/cloud/discoveryengine/v1/internal/engine_stub_factory.cc index 398d1f09832c2..aa17424d54d06 100644 --- a/google/cloud/discoveryengine/v1/internal/engine_stub_factory.cc +++ b/google/cloud/discoveryengine/v1/internal/engine_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 CreateDefaultEngineServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::discoveryengine::v1::EngineService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/discoveryengine/v1/internal/engine_tracing_connection.cc b/google/cloud/discoveryengine/v1/internal/engine_tracing_connection.cc index b5d2b0c1da4b9..f87adc6628303 100644 --- a/google/cloud/discoveryengine/v1/internal/engine_tracing_connection.cc +++ b/google/cloud/discoveryengine/v1/internal/engine_tracing_connection.cc @@ -119,6 +119,34 @@ EngineServiceTracingConnection::ListEngines( std::move(sr)); } +StreamRange +EngineServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::EngineServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +EngineServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::EngineServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status EngineServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::EngineServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/discoveryengine/v1/internal/engine_tracing_connection.h b/google/cloud/discoveryengine/v1/internal/engine_tracing_connection.h index ac976211d8630..0ca0744ebd2d0 100644 --- a/google/cloud/discoveryengine/v1/internal/engine_tracing_connection.h +++ b/google/cloud/discoveryengine/v1/internal/engine_tracing_connection.h @@ -75,6 +75,15 @@ class EngineServiceTracingConnection StreamRange ListEngines( google::cloud::discoveryengine::v1::ListEnginesRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/discoveryengine/v1/internal/engine_tracing_stub.cc b/google/cloud/discoveryengine/v1/internal/engine_tracing_stub.cc index 6b30dd7a9790b..672c2e3fe17ea 100644 --- a/google/cloud/discoveryengine/v1/internal/engine_tracing_stub.cc +++ b/google/cloud/discoveryengine/v1/internal/engine_tracing_stub.cc @@ -118,6 +118,40 @@ EngineServiceTracingStub::ListEngines( child_->ListEngines(context, options, request)); } +StatusOr +EngineServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.EngineService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr EngineServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.EngineService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status EngineServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.EngineService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + future> EngineServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/engine_tracing_stub.h b/google/cloud/discoveryengine/v1/internal/engine_tracing_stub.h index 2c1df454aea26..fbfeddc505867 100644 --- a/google/cloud/discoveryengine/v1/internal/engine_tracing_stub.h +++ b/google/cloud/discoveryengine/v1/internal/engine_tracing_stub.h @@ -77,6 +77,18 @@ class EngineServiceTracingStub : public EngineServiceStub { google::cloud::discoveryengine::v1::ListEnginesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/grounded_generation_auth_decorator.cc b/google/cloud/discoveryengine/v1/internal/grounded_generation_auth_decorator.cc index 0720305f355a7..7c72c482d02a1 100644 --- a/google/cloud/discoveryengine/v1/internal/grounded_generation_auth_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/grounded_generation_auth_decorator.cc @@ -40,6 +40,32 @@ GroundedGenerationServiceAuth::CheckGrounding( return child_->CheckGrounding(context, options, request); } +StatusOr +GroundedGenerationServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +GroundedGenerationServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status GroundedGenerationServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/grounded_generation_auth_decorator.h b/google/cloud/discoveryengine/v1/internal/grounded_generation_auth_decorator.h index 7a8a49e2bc4ad..1f38e60d1f3e2 100644 --- a/google/cloud/discoveryengine/v1/internal/grounded_generation_auth_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/grounded_generation_auth_decorator.h @@ -44,6 +44,18 @@ class GroundedGenerationServiceAuth : public GroundedGenerationServiceStub { google::cloud::discoveryengine::v1::CheckGroundingRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/discoveryengine/v1/internal/grounded_generation_connection_impl.cc b/google/cloud/discoveryengine/v1/internal/grounded_generation_connection_impl.cc index cf3f9cffb46d9..57331a2b9dfd9 100644 --- a/google/cloud/discoveryengine/v1/internal/grounded_generation_connection_impl.cc +++ b/google/cloud/discoveryengine/v1/internal/grounded_generation_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 @@ -83,6 +84,67 @@ GroundedGenerationServiceConnectionImpl::CheckGrounding( *current, request, __func__); } +StreamRange +GroundedGenerationServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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< + discoveryengine_v1::GroundedGenerationServiceRetryPolicy>( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +GroundedGenerationServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status GroundedGenerationServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/grounded_generation_connection_impl.h b/google/cloud/discoveryengine/v1/internal/grounded_generation_connection_impl.h index 179065b1a6f57..1e495039e8701 100644 --- a/google/cloud/discoveryengine/v1/internal/grounded_generation_connection_impl.h +++ b/google/cloud/discoveryengine/v1/internal/grounded_generation_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 @@ -55,6 +56,15 @@ class GroundedGenerationServiceConnectionImpl google::cloud::discoveryengine::v1::CheckGroundingRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr diff --git a/google/cloud/discoveryengine/v1/internal/grounded_generation_logging_decorator.cc b/google/cloud/discoveryengine/v1/internal/grounded_generation_logging_decorator.cc index 5255566b70532..cf5d8ebcd6290 100644 --- a/google/cloud/discoveryengine/v1/internal/grounded_generation_logging_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/grounded_generation_logging_decorator.cc @@ -48,6 +48,41 @@ GroundedGenerationServiceLogging::CheckGrounding( context, options, request, __func__, tracing_options_); } +StatusOr +GroundedGenerationServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +GroundedGenerationServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status GroundedGenerationServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/grounded_generation_logging_decorator.h b/google/cloud/discoveryengine/v1/internal/grounded_generation_logging_decorator.h index ef86871eff68b..98803cadc8139 100644 --- a/google/cloud/discoveryengine/v1/internal/grounded_generation_logging_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/grounded_generation_logging_decorator.h @@ -44,6 +44,18 @@ class GroundedGenerationServiceLogging : public GroundedGenerationServiceStub { google::cloud::discoveryengine::v1::CheckGroundingRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/discoveryengine/v1/internal/grounded_generation_metadata_decorator.cc b/google/cloud/discoveryengine/v1/internal/grounded_generation_metadata_decorator.cc index b149bf414eb44..ea0bc2b90bc92 100644 --- a/google/cloud/discoveryengine/v1/internal/grounded_generation_metadata_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/grounded_generation_metadata_decorator.cc @@ -54,6 +54,32 @@ GroundedGenerationServiceMetadata::CheckGrounding( return child_->CheckGrounding(context, options, request); } +StatusOr +GroundedGenerationServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +GroundedGenerationServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status GroundedGenerationServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + void GroundedGenerationServiceMetadata::SetMetadata( grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/discoveryengine/v1/internal/grounded_generation_metadata_decorator.h b/google/cloud/discoveryengine/v1/internal/grounded_generation_metadata_decorator.h index 061fe6ca83f87..a04b3f83a9590 100644 --- a/google/cloud/discoveryengine/v1/internal/grounded_generation_metadata_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/grounded_generation_metadata_decorator.h @@ -45,6 +45,18 @@ class GroundedGenerationServiceMetadata : public GroundedGenerationServiceStub { google::cloud::discoveryengine::v1::CheckGroundingRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/discoveryengine/v1/internal/grounded_generation_stub.cc b/google/cloud/discoveryengine/v1/internal/grounded_generation_stub.cc index 626658a90d25f..aaa049d676484 100644 --- a/google/cloud/discoveryengine/v1/internal/grounded_generation_stub.cc +++ b/google/cloud/discoveryengine/v1/internal/grounded_generation_stub.cc @@ -42,6 +42,41 @@ DefaultGroundedGenerationServiceStub::CheckGrounding( return response; } +StatusOr +DefaultGroundedGenerationServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultGroundedGenerationServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultGroundedGenerationServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/grounded_generation_stub.h b/google/cloud/discoveryengine/v1/internal/grounded_generation_stub.h index af0127df93c55..6ed6d9ef115c1 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 @@ -40,6 +41,18 @@ class GroundedGenerationServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::discoveryengine::v1::CheckGroundingRequest const& request) = 0; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultGroundedGenerationServiceStub @@ -48,8 +61,11 @@ class DefaultGroundedGenerationServiceStub explicit DefaultGroundedGenerationServiceStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr CheckGrounding( @@ -57,10 +73,24 @@ class DefaultGroundedGenerationServiceStub google::cloud::discoveryengine::v1::CheckGroundingRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/discoveryengine/v1/internal/grounded_generation_stub_factory.cc b/google/cloud/discoveryengine/v1/internal/grounded_generation_stub_factory.cc index 57de433f7b3db..6e3cf8ce27cf7 100644 --- a/google/cloud/discoveryengine/v1/internal/grounded_generation_stub_factory.cc +++ b/google/cloud/discoveryengine/v1/internal/grounded_generation_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 @@ CreateDefaultGroundedGenerationServiceStub( auto service_grpc_stub = google::cloud::discoveryengine::v1::GroundedGenerationService::NewStub( channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_operations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/discoveryengine/v1/internal/grounded_generation_tracing_connection.cc b/google/cloud/discoveryengine/v1/internal/grounded_generation_tracing_connection.cc index 9cbc5b001c5a8..95200c3df36f2 100644 --- a/google/cloud/discoveryengine/v1/internal/grounded_generation_tracing_connection.cc +++ b/google/cloud/discoveryengine/v1/internal/grounded_generation_tracing_connection.cc @@ -18,6 +18,7 @@ #include "google/cloud/discoveryengine/v1/internal/grounded_generation_tracing_connection.h" #include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" #include #include @@ -44,6 +45,36 @@ GroundedGenerationServiceTracingConnection::CheckGrounding( return internal::EndSpan(*span, child_->CheckGrounding(request)); } +StreamRange +GroundedGenerationServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::GroundedGenerationServiceConnection::" + "ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +GroundedGenerationServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::GroundedGenerationServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status GroundedGenerationServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::GroundedGenerationServiceConnection::" + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/discoveryengine/v1/internal/grounded_generation_tracing_connection.h b/google/cloud/discoveryengine/v1/internal/grounded_generation_tracing_connection.h index c1b57e72d73a8..1cb3e8789de6e 100644 --- a/google/cloud/discoveryengine/v1/internal/grounded_generation_tracing_connection.h +++ b/google/cloud/discoveryengine/v1/internal/grounded_generation_tracing_connection.h @@ -46,6 +46,15 @@ class GroundedGenerationServiceTracingConnection google::cloud::discoveryengine::v1::CheckGroundingRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; diff --git a/google/cloud/discoveryengine/v1/internal/grounded_generation_tracing_stub.cc b/google/cloud/discoveryengine/v1/internal/grounded_generation_tracing_stub.cc index cdafcae8f81dd..3287c71b21a1f 100644 --- a/google/cloud/discoveryengine/v1/internal/grounded_generation_tracing_stub.cc +++ b/google/cloud/discoveryengine/v1/internal/grounded_generation_tracing_stub.cc @@ -45,6 +45,44 @@ GroundedGenerationServiceTracingStub::CheckGrounding( child_->CheckGrounding(context, options, request)); } +StatusOr +GroundedGenerationServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.GroundedGenerationService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +GroundedGenerationServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.GroundedGenerationService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status GroundedGenerationServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.GroundedGenerationService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/discoveryengine/v1/internal/grounded_generation_tracing_stub.h b/google/cloud/discoveryengine/v1/internal/grounded_generation_tracing_stub.h index c86fa0b93cce2..4d68ac867bd52 100644 --- a/google/cloud/discoveryengine/v1/internal/grounded_generation_tracing_stub.h +++ b/google/cloud/discoveryengine/v1/internal/grounded_generation_tracing_stub.h @@ -46,6 +46,18 @@ class GroundedGenerationServiceTracingStub google::cloud::discoveryengine::v1::CheckGroundingRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/discoveryengine/v1/internal/project_auth_decorator.cc b/google/cloud/discoveryengine/v1/internal/project_auth_decorator.cc index e3fb978548f76..0ca6a327ea1bb 100644 --- a/google/cloud/discoveryengine/v1/internal/project_auth_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/project_auth_decorator.cc @@ -61,6 +61,31 @@ StatusOr ProjectServiceAuth::ProvisionProject( return child_->ProvisionProject(context, options, request); } +StatusOr +ProjectServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr ProjectServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status ProjectServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + future> ProjectServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/project_auth_decorator.h b/google/cloud/discoveryengine/v1/internal/project_auth_decorator.h index 993dbceb5106b..be5cc030ae373 100644 --- a/google/cloud/discoveryengine/v1/internal/project_auth_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/project_auth_decorator.h @@ -51,6 +51,18 @@ class ProjectServiceAuth : public ProjectServiceStub { google::cloud::discoveryengine::v1::ProvisionProjectRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/project_connection_impl.cc b/google/cloud/discoveryengine/v1/internal/project_connection_impl.cc index 30637e6964c6a..8c8405b99ac08 100644 --- a/google/cloud/discoveryengine/v1/internal/project_connection_impl.cc +++ b/google/cloud/discoveryengine/v1/internal/project_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 @@ -163,6 +164,66 @@ ProjectServiceConnectionImpl::ProvisionProject( polling_policy(*current), __func__); } +StreamRange +ProjectServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ProjectServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ProjectServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/project_connection_impl.h b/google/cloud/discoveryengine/v1/internal/project_connection_impl.h index d4b2d3ffffe54..59f70bce44f88 100644 --- a/google/cloud/discoveryengine/v1/internal/project_connection_impl.h +++ b/google/cloud/discoveryengine/v1/internal/project_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 @@ -64,6 +65,15 @@ class ProjectServiceConnectionImpl future> ProvisionProject(google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/discoveryengine/v1/internal/project_logging_decorator.cc b/google/cloud/discoveryengine/v1/internal/project_logging_decorator.cc index d5339228cfd5e..e4325fab2a566 100644 --- a/google/cloud/discoveryengine/v1/internal/project_logging_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/project_logging_decorator.cc @@ -69,6 +69,40 @@ ProjectServiceLogging::ProvisionProject( context, options, request, __func__, tracing_options_); } +StatusOr +ProjectServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ProjectServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ProjectServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> ProjectServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/project_logging_decorator.h b/google/cloud/discoveryengine/v1/internal/project_logging_decorator.h index 6674ce74ef218..1b753de110d96 100644 --- a/google/cloud/discoveryengine/v1/internal/project_logging_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/project_logging_decorator.h @@ -51,6 +51,18 @@ class ProjectServiceLogging : public ProjectServiceStub { google::cloud::discoveryengine::v1::ProvisionProjectRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/project_metadata_decorator.cc b/google/cloud/discoveryengine/v1/internal/project_metadata_decorator.cc index 38f6602d2d003..d3ee74b157bb9 100644 --- a/google/cloud/discoveryengine/v1/internal/project_metadata_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/project_metadata_decorator.cc @@ -67,6 +67,31 @@ ProjectServiceMetadata::ProvisionProject( return child_->ProvisionProject(context, options, request); } +StatusOr +ProjectServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr ProjectServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status ProjectServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + future> ProjectServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/project_metadata_decorator.h b/google/cloud/discoveryengine/v1/internal/project_metadata_decorator.h index a71938f029d86..4fd4ef9d9584b 100644 --- a/google/cloud/discoveryengine/v1/internal/project_metadata_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/project_metadata_decorator.h @@ -51,6 +51,18 @@ class ProjectServiceMetadata : public ProjectServiceStub { google::cloud::discoveryengine::v1::ProvisionProjectRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/project_stub.cc b/google/cloud/discoveryengine/v1/internal/project_stub.cc index ba8f75dc1344f..510ae36a3730f 100644 --- a/google/cloud/discoveryengine/v1/internal/project_stub.cc +++ b/google/cloud/discoveryengine/v1/internal/project_stub.cc @@ -64,6 +64,41 @@ DefaultProjectServiceStub::ProvisionProject( return response; } +StatusOr +DefaultProjectServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultProjectServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultProjectServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + future> DefaultProjectServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/project_stub.h b/google/cloud/discoveryengine/v1/internal/project_stub.h index 8da980b0a38b0..540ee2264a516 100644 --- a/google/cloud/discoveryengine/v1/internal/project_stub.h +++ b/google/cloud/discoveryengine/v1/internal/project_stub.h @@ -51,6 +51,18 @@ class ProjectServiceStub { google::cloud::discoveryengine::v1::ProvisionProjectRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -70,9 +82,13 @@ class DefaultProjectServiceStub : public ProjectServiceStub { std::unique_ptr< google::cloud::discoveryengine::v1::ProjectService::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} future> AsyncProvisionProject( google::cloud::CompletionQueue& cq, @@ -86,6 +102,18 @@ class DefaultProjectServiceStub : public ProjectServiceStub { google::cloud::discoveryengine::v1::ProvisionProjectRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -102,6 +130,8 @@ class DefaultProjectServiceStub : public ProjectServiceStub { std::unique_ptr< google::cloud::discoveryengine::v1::ProjectService::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/discoveryengine/v1/internal/project_stub_factory.cc b/google/cloud/discoveryengine/v1/internal/project_stub_factory.cc index 5bdf951fe2c25..0c7b81e4e1e9d 100644 --- a/google/cloud/discoveryengine/v1/internal/project_stub_factory.cc +++ b/google/cloud/discoveryengine/v1/internal/project_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 CreateDefaultProjectServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::discoveryengine::v1::ProjectService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/discoveryengine/v1/internal/project_tracing_connection.cc b/google/cloud/discoveryengine/v1/internal/project_tracing_connection.cc index 82d17b0f69c39..6211f5c509f5e 100644 --- a/google/cloud/discoveryengine/v1/internal/project_tracing_connection.cc +++ b/google/cloud/discoveryengine/v1/internal/project_tracing_connection.cc @@ -18,6 +18,7 @@ #include "google/cloud/discoveryengine/v1/internal/project_tracing_connection.h" #include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" #include #include @@ -64,6 +65,34 @@ ProjectServiceTracingConnection::ProvisionProject( child_->ProvisionProject(operation)); } +StreamRange +ProjectServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::ProjectServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ProjectServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::ProjectServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status ProjectServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::ProjectServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/discoveryengine/v1/internal/project_tracing_connection.h b/google/cloud/discoveryengine/v1/internal/project_tracing_connection.h index 8c657cf05dd97..44b0319842f06 100644 --- a/google/cloud/discoveryengine/v1/internal/project_tracing_connection.h +++ b/google/cloud/discoveryengine/v1/internal/project_tracing_connection.h @@ -53,6 +53,15 @@ class ProjectServiceTracingConnection future> ProvisionProject(google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/discoveryengine/v1/internal/project_tracing_stub.cc b/google/cloud/discoveryengine/v1/internal/project_tracing_stub.cc index 921d0ffdc8b1f..aff9e88719194 100644 --- a/google/cloud/discoveryengine/v1/internal/project_tracing_stub.cc +++ b/google/cloud/discoveryengine/v1/internal/project_tracing_stub.cc @@ -61,6 +61,41 @@ ProjectServiceTracingStub::ProvisionProject( child_->ProvisionProject(context, options, request)); } +StatusOr +ProjectServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.ProjectService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +ProjectServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.ProjectService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status ProjectServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.ProjectService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + future> ProjectServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/project_tracing_stub.h b/google/cloud/discoveryengine/v1/internal/project_tracing_stub.h index 070ec312f95d3..99bce2b450fc9 100644 --- a/google/cloud/discoveryengine/v1/internal/project_tracing_stub.h +++ b/google/cloud/discoveryengine/v1/internal/project_tracing_stub.h @@ -50,6 +50,18 @@ class ProjectServiceTracingStub : public ProjectServiceStub { google::cloud::discoveryengine::v1::ProvisionProjectRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/rank_auth_decorator.cc b/google/cloud/discoveryengine/v1/internal/rank_auth_decorator.cc index 2a6461a100d01..afbd02d36ac8f 100644 --- a/google/cloud/discoveryengine/v1/internal/rank_auth_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/rank_auth_decorator.cc @@ -40,6 +40,31 @@ RankServiceAuth::Rank( return child_->Rank(context, options, request); } +StatusOr +RankServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr RankServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status RankServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/rank_auth_decorator.h b/google/cloud/discoveryengine/v1/internal/rank_auth_decorator.h index 7ceb810cc0608..0a5464f04d85e 100644 --- a/google/cloud/discoveryengine/v1/internal/rank_auth_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/rank_auth_decorator.h @@ -42,6 +42,18 @@ class RankServiceAuth : public RankServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::discoveryengine::v1::RankRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/discoveryengine/v1/internal/rank_connection_impl.cc b/google/cloud/discoveryengine/v1/internal/rank_connection_impl.cc index 47aec75194dca..3bee664e1a3f4 100644 --- a/google/cloud/discoveryengine/v1/internal/rank_connection_impl.cc +++ b/google/cloud/discoveryengine/v1/internal/rank_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 @@ -74,6 +75,66 @@ RankServiceConnectionImpl::Rank( *current, request, __func__); } +StreamRange +RankServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +RankServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status RankServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/rank_connection_impl.h b/google/cloud/discoveryengine/v1/internal/rank_connection_impl.h index 530b21828c4be..04e2af8bb9272 100644 --- a/google/cloud/discoveryengine/v1/internal/rank_connection_impl.h +++ b/google/cloud/discoveryengine/v1/internal/rank_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 @@ -51,6 +52,15 @@ class RankServiceConnectionImpl StatusOr Rank( google::cloud::discoveryengine::v1::RankRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/discoveryengine/v1/internal/rank_logging_decorator.cc b/google/cloud/discoveryengine/v1/internal/rank_logging_decorator.cc index 456977b952cda..a46b891a73321 100644 --- a/google/cloud/discoveryengine/v1/internal/rank_logging_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/rank_logging_decorator.cc @@ -47,6 +47,40 @@ RankServiceLogging::Rank( context, options, request, __func__, tracing_options_); } +StatusOr +RankServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr RankServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status RankServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/rank_logging_decorator.h b/google/cloud/discoveryengine/v1/internal/rank_logging_decorator.h index bd942cc1aa251..7ac257e0a45bb 100644 --- a/google/cloud/discoveryengine/v1/internal/rank_logging_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/rank_logging_decorator.h @@ -42,6 +42,18 @@ class RankServiceLogging : public RankServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::discoveryengine::v1::RankRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/discoveryengine/v1/internal/rank_metadata_decorator.cc b/google/cloud/discoveryengine/v1/internal/rank_metadata_decorator.cc index 281d3db715e03..8ae9eb26bedf6 100644 --- a/google/cloud/discoveryengine/v1/internal/rank_metadata_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/rank_metadata_decorator.cc @@ -54,6 +54,31 @@ RankServiceMetadata::Rank( return child_->Rank(context, options, request); } +StatusOr +RankServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr RankServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status RankServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + void RankServiceMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/discoveryengine/v1/internal/rank_metadata_decorator.h b/google/cloud/discoveryengine/v1/internal/rank_metadata_decorator.h index 13795739ba373..665e333c6911f 100644 --- a/google/cloud/discoveryengine/v1/internal/rank_metadata_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/rank_metadata_decorator.h @@ -42,6 +42,18 @@ class RankServiceMetadata : public RankServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::discoveryengine::v1::RankRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/discoveryengine/v1/internal/rank_stub.cc b/google/cloud/discoveryengine/v1/internal/rank_stub.cc index 0d0f8a172d85c..c1698914f47f7 100644 --- a/google/cloud/discoveryengine/v1/internal/rank_stub.cc +++ b/google/cloud/discoveryengine/v1/internal/rank_stub.cc @@ -42,6 +42,40 @@ DefaultRankServiceStub::Rank( return response; } +StatusOr +DefaultRankServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultRankServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultRankServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/rank_stub.h b/google/cloud/discoveryengine/v1/internal/rank_stub.h index 7d1be2e9aa182..e5de4b4515e43 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 @@ -38,6 +39,18 @@ class RankServiceStub { virtual StatusOr Rank( grpc::ClientContext& context, Options const& options, google::cloud::discoveryengine::v1::RankRequest const& request) = 0; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultRankServiceStub : public RankServiceStub { @@ -45,17 +58,34 @@ class DefaultRankServiceStub : public RankServiceStub { explicit DefaultRankServiceStub( std::unique_ptr< google::cloud::discoveryengine::v1::RankService::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr Rank( grpc::ClientContext& context, Options const& options, google::cloud::discoveryengine::v1::RankRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr< google::cloud::discoveryengine::v1::RankService::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/discoveryengine/v1/internal/rank_stub_factory.cc b/google/cloud/discoveryengine/v1/internal/rank_stub_factory.cc index 7b8bdd0e4c075..3560b93aac2a8 100644 --- a/google/cloud/discoveryengine/v1/internal/rank_stub_factory.cc +++ b/google/cloud/discoveryengine/v1/internal/rank_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 CreateDefaultRankServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::discoveryengine::v1::RankService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), std::move(stub)); diff --git a/google/cloud/discoveryengine/v1/internal/rank_tracing_connection.cc b/google/cloud/discoveryengine/v1/internal/rank_tracing_connection.cc index 39e0f0eadebc0..4c65538171c5f 100644 --- a/google/cloud/discoveryengine/v1/internal/rank_tracing_connection.cc +++ b/google/cloud/discoveryengine/v1/internal/rank_tracing_connection.cc @@ -18,6 +18,7 @@ #include "google/cloud/discoveryengine/v1/internal/rank_tracing_connection.h" #include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" #include #include @@ -41,6 +42,34 @@ RankServiceTracingConnection::Rank( return internal::EndSpan(*span, child_->Rank(request)); } +StreamRange +RankServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::RankServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +RankServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::RankServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status RankServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::RankServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/discoveryengine/v1/internal/rank_tracing_connection.h b/google/cloud/discoveryengine/v1/internal/rank_tracing_connection.h index ba35a14d4611d..01b3665491011 100644 --- a/google/cloud/discoveryengine/v1/internal/rank_tracing_connection.h +++ b/google/cloud/discoveryengine/v1/internal/rank_tracing_connection.h @@ -43,6 +43,15 @@ class RankServiceTracingConnection StatusOr Rank( google::cloud::discoveryengine::v1::RankRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/discoveryengine/v1/internal/rank_tracing_stub.cc b/google/cloud/discoveryengine/v1/internal/rank_tracing_stub.cc index 0a964d3c1bb08..45ff8ecd3f45e 100644 --- a/google/cloud/discoveryengine/v1/internal/rank_tracing_stub.cc +++ b/google/cloud/discoveryengine/v1/internal/rank_tracing_stub.cc @@ -44,6 +44,40 @@ RankServiceTracingStub::Rank( child_->Rank(context, options, request)); } +StatusOr +RankServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.RankService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr RankServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.RankService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status RankServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.RankService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeRankServiceTracingStub( diff --git a/google/cloud/discoveryengine/v1/internal/rank_tracing_stub.h b/google/cloud/discoveryengine/v1/internal/rank_tracing_stub.h index d6651b831439c..a908ee498afba 100644 --- a/google/cloud/discoveryengine/v1/internal/rank_tracing_stub.h +++ b/google/cloud/discoveryengine/v1/internal/rank_tracing_stub.h @@ -42,6 +42,18 @@ class RankServiceTracingStub : public RankServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::discoveryengine::v1::RankRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/discoveryengine/v1/internal/recommendation_auth_decorator.cc b/google/cloud/discoveryengine/v1/internal/recommendation_auth_decorator.cc index 1c4d18e467795..ff5b4c990c09f 100644 --- a/google/cloud/discoveryengine/v1/internal/recommendation_auth_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/recommendation_auth_decorator.cc @@ -40,6 +40,32 @@ RecommendationServiceAuth::Recommend( return child_->Recommend(context, options, request); } +StatusOr +RecommendationServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +RecommendationServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status RecommendationServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/recommendation_auth_decorator.h b/google/cloud/discoveryengine/v1/internal/recommendation_auth_decorator.h index 03b69dad02edb..27f756c14d3f9 100644 --- a/google/cloud/discoveryengine/v1/internal/recommendation_auth_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/recommendation_auth_decorator.h @@ -43,6 +43,18 @@ class RecommendationServiceAuth : public RecommendationServiceStub { google::cloud::discoveryengine::v1::RecommendRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/discoveryengine/v1/internal/recommendation_connection_impl.cc b/google/cloud/discoveryengine/v1/internal/recommendation_connection_impl.cc index be3baa876beea..7243aa90bb7a0 100644 --- a/google/cloud/discoveryengine/v1/internal/recommendation_connection_impl.cc +++ b/google/cloud/discoveryengine/v1/internal/recommendation_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 @@ -80,6 +81,67 @@ RecommendationServiceConnectionImpl::Recommend( *current, request, __func__); } +StreamRange +RecommendationServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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< + discoveryengine_v1::RecommendationServiceRetryPolicy>( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +RecommendationServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status RecommendationServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/recommendation_connection_impl.h b/google/cloud/discoveryengine/v1/internal/recommendation_connection_impl.h index ed0a3b23d456b..6bde1c3041311 100644 --- a/google/cloud/discoveryengine/v1/internal/recommendation_connection_impl.h +++ b/google/cloud/discoveryengine/v1/internal/recommendation_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,15 @@ class RecommendationServiceConnectionImpl google::cloud::discoveryengine::v1::RecommendRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/discoveryengine/v1/internal/recommendation_logging_decorator.cc b/google/cloud/discoveryengine/v1/internal/recommendation_logging_decorator.cc index 096f48b6e44a8..c76c42f255714 100644 --- a/google/cloud/discoveryengine/v1/internal/recommendation_logging_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/recommendation_logging_decorator.cc @@ -48,6 +48,41 @@ RecommendationServiceLogging::Recommend( context, options, request, __func__, tracing_options_); } +StatusOr +RecommendationServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +RecommendationServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status RecommendationServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/recommendation_logging_decorator.h b/google/cloud/discoveryengine/v1/internal/recommendation_logging_decorator.h index 043e802c49e4c..3539071e225bb 100644 --- a/google/cloud/discoveryengine/v1/internal/recommendation_logging_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/recommendation_logging_decorator.h @@ -43,6 +43,18 @@ class RecommendationServiceLogging : public RecommendationServiceStub { google::cloud::discoveryengine::v1::RecommendRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/discoveryengine/v1/internal/recommendation_metadata_decorator.cc b/google/cloud/discoveryengine/v1/internal/recommendation_metadata_decorator.cc index acdce4f87c62b..165a96d52dbd6 100644 --- a/google/cloud/discoveryengine/v1/internal/recommendation_metadata_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/recommendation_metadata_decorator.cc @@ -54,6 +54,32 @@ RecommendationServiceMetadata::Recommend( return child_->Recommend(context, options, request); } +StatusOr +RecommendationServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +RecommendationServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status RecommendationServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + void RecommendationServiceMetadata::SetMetadata( grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/discoveryengine/v1/internal/recommendation_metadata_decorator.h b/google/cloud/discoveryengine/v1/internal/recommendation_metadata_decorator.h index 6e3b73fc4d4f2..f33a6e2e829b9 100644 --- a/google/cloud/discoveryengine/v1/internal/recommendation_metadata_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/recommendation_metadata_decorator.h @@ -44,6 +44,18 @@ class RecommendationServiceMetadata : public RecommendationServiceStub { google::cloud::discoveryengine::v1::RecommendRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/discoveryengine/v1/internal/recommendation_stub.cc b/google/cloud/discoveryengine/v1/internal/recommendation_stub.cc index 55e862c3a1229..5368fdb04542a 100644 --- a/google/cloud/discoveryengine/v1/internal/recommendation_stub.cc +++ b/google/cloud/discoveryengine/v1/internal/recommendation_stub.cc @@ -42,6 +42,41 @@ DefaultRecommendationServiceStub::Recommend( return response; } +StatusOr +DefaultRecommendationServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultRecommendationServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultRecommendationServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/recommendation_stub.h b/google/cloud/discoveryengine/v1/internal/recommendation_stub.h index 2342ca9626a43..06e9005151068 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 @@ -39,6 +40,18 @@ class RecommendationServiceStub { Recommend( grpc::ClientContext& context, Options const& options, google::cloud::discoveryengine::v1::RecommendRequest const& request) = 0; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultRecommendationServiceStub : public RecommendationServiceStub { @@ -46,18 +59,35 @@ class DefaultRecommendationServiceStub : public RecommendationServiceStub { explicit DefaultRecommendationServiceStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr Recommend( grpc::ClientContext& context, Options const& options, google::cloud::discoveryengine::v1::RecommendRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr< google::cloud::discoveryengine::v1::RecommendationService::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/discoveryengine/v1/internal/recommendation_stub_factory.cc b/google/cloud/discoveryengine/v1/internal/recommendation_stub_factory.cc index a66f319741309..aa5321901a2de 100644 --- a/google/cloud/discoveryengine/v1/internal/recommendation_stub_factory.cc +++ b/google/cloud/discoveryengine/v1/internal/recommendation_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 @@ CreateDefaultRecommendationServiceStub( auto service_grpc_stub = google::cloud::discoveryengine::v1::RecommendationService::NewStub( channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_operations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/discoveryengine/v1/internal/recommendation_tracing_connection.cc b/google/cloud/discoveryengine/v1/internal/recommendation_tracing_connection.cc index e6392ae22aa38..56ebdb8f20fe0 100644 --- a/google/cloud/discoveryengine/v1/internal/recommendation_tracing_connection.cc +++ b/google/cloud/discoveryengine/v1/internal/recommendation_tracing_connection.cc @@ -18,6 +18,7 @@ #include "google/cloud/discoveryengine/v1/internal/recommendation_tracing_connection.h" #include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" #include #include @@ -41,6 +42,34 @@ RecommendationServiceTracingConnection::Recommend( return internal::EndSpan(*span, child_->Recommend(request)); } +StreamRange +RecommendationServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::RecommendationServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +RecommendationServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::RecommendationServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status RecommendationServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::RecommendationServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/discoveryengine/v1/internal/recommendation_tracing_connection.h b/google/cloud/discoveryengine/v1/internal/recommendation_tracing_connection.h index b4897a3beaef1..a0165b3e9cbc5 100644 --- a/google/cloud/discoveryengine/v1/internal/recommendation_tracing_connection.h +++ b/google/cloud/discoveryengine/v1/internal/recommendation_tracing_connection.h @@ -45,6 +45,15 @@ class RecommendationServiceTracingConnection google::cloud::discoveryengine::v1::RecommendRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/discoveryengine/v1/internal/recommendation_tracing_stub.cc b/google/cloud/discoveryengine/v1/internal/recommendation_tracing_stub.cc index 2632fb70219a8..f3fa9ca14c512 100644 --- a/google/cloud/discoveryengine/v1/internal/recommendation_tracing_stub.cc +++ b/google/cloud/discoveryengine/v1/internal/recommendation_tracing_stub.cc @@ -44,6 +44,43 @@ RecommendationServiceTracingStub::Recommend( child_->Recommend(context, options, request)); } +StatusOr +RecommendationServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.RecommendationService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +RecommendationServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.RecommendationService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status RecommendationServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.RecommendationService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeRecommendationServiceTracingStub( diff --git a/google/cloud/discoveryengine/v1/internal/recommendation_tracing_stub.h b/google/cloud/discoveryengine/v1/internal/recommendation_tracing_stub.h index 52041b791a1e8..a2918b9e3b2bf 100644 --- a/google/cloud/discoveryengine/v1/internal/recommendation_tracing_stub.h +++ b/google/cloud/discoveryengine/v1/internal/recommendation_tracing_stub.h @@ -44,6 +44,18 @@ class RecommendationServiceTracingStub : public RecommendationServiceStub { google::cloud::discoveryengine::v1::RecommendRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/discoveryengine/v1/internal/schema_auth_decorator.cc b/google/cloud/discoveryengine/v1/internal/schema_auth_decorator.cc index 99c48364ca10f..bc5e120e6ad98 100644 --- a/google/cloud/discoveryengine/v1/internal/schema_auth_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/schema_auth_decorator.cc @@ -133,6 +133,31 @@ StatusOr SchemaServiceAuth::DeleteSchema( return child_->DeleteSchema(context, options, request); } +StatusOr +SchemaServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr SchemaServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status SchemaServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + future> SchemaServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/schema_auth_decorator.h b/google/cloud/discoveryengine/v1/internal/schema_auth_decorator.h index 8b4ecdc976201..ebb9e62f60b82 100644 --- a/google/cloud/discoveryengine/v1/internal/schema_auth_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/schema_auth_decorator.h @@ -85,6 +85,18 @@ class SchemaServiceAuth : public SchemaServiceStub { google::cloud::discoveryengine::v1::DeleteSchemaRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/schema_connection_impl.cc b/google/cloud/discoveryengine/v1/internal/schema_connection_impl.cc index a471c1ed1c2e4..0d0bb1611be0e 100644 --- a/google/cloud/discoveryengine/v1/internal/schema_connection_impl.cc +++ b/google/cloud/discoveryengine/v1/internal/schema_connection_impl.cc @@ -398,6 +398,66 @@ SchemaServiceConnectionImpl::DeleteSchema( polling_policy(*current), __func__); } +StreamRange +SchemaServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +SchemaServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status SchemaServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/schema_connection_impl.h b/google/cloud/discoveryengine/v1/internal/schema_connection_impl.h index f7f5d09e85ec9..08a153668f18c 100644 --- a/google/cloud/discoveryengine/v1/internal/schema_connection_impl.h +++ b/google/cloud/discoveryengine/v1/internal/schema_connection_impl.h @@ -95,6 +95,15 @@ class SchemaServiceConnectionImpl future> DeleteSchema(google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/discoveryengine/v1/internal/schema_logging_decorator.cc b/google/cloud/discoveryengine/v1/internal/schema_logging_decorator.cc index b0e903a571ee2..34bf0c2c3e9fb 100644 --- a/google/cloud/discoveryengine/v1/internal/schema_logging_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/schema_logging_decorator.cc @@ -154,6 +154,40 @@ StatusOr SchemaServiceLogging::DeleteSchema( context, options, request, __func__, tracing_options_); } +StatusOr +SchemaServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr SchemaServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status SchemaServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> SchemaServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/schema_logging_decorator.h b/google/cloud/discoveryengine/v1/internal/schema_logging_decorator.h index 701f9cdb5030b..51d498631cffb 100644 --- a/google/cloud/discoveryengine/v1/internal/schema_logging_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/schema_logging_decorator.h @@ -85,6 +85,18 @@ class SchemaServiceLogging : public SchemaServiceStub { google::cloud::discoveryengine::v1::DeleteSchemaRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/schema_metadata_decorator.cc b/google/cloud/discoveryengine/v1/internal/schema_metadata_decorator.cc index cca94d2853ad7..83a10a84ac4d4 100644 --- a/google/cloud/discoveryengine/v1/internal/schema_metadata_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/schema_metadata_decorator.cc @@ -124,6 +124,31 @@ StatusOr SchemaServiceMetadata::DeleteSchema( return child_->DeleteSchema(context, options, request); } +StatusOr +SchemaServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr SchemaServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status SchemaServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + future> SchemaServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/schema_metadata_decorator.h b/google/cloud/discoveryengine/v1/internal/schema_metadata_decorator.h index c86600b551b1d..36869f36a7b74 100644 --- a/google/cloud/discoveryengine/v1/internal/schema_metadata_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/schema_metadata_decorator.h @@ -85,6 +85,18 @@ class SchemaServiceMetadata : public SchemaServiceStub { google::cloud::discoveryengine::v1::DeleteSchemaRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/schema_stub.cc b/google/cloud/discoveryengine/v1/internal/schema_stub.cc index c2028f9fd6908..c02a840248b9a 100644 --- a/google/cloud/discoveryengine/v1/internal/schema_stub.cc +++ b/google/cloud/discoveryengine/v1/internal/schema_stub.cc @@ -145,6 +145,40 @@ StatusOr DefaultSchemaServiceStub::DeleteSchema( return response; } +StatusOr +DefaultSchemaServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultSchemaServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultSchemaServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + future> DefaultSchemaServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/schema_stub.h b/google/cloud/discoveryengine/v1/internal/schema_stub.h index a6f685111f997..4063c0c6ec900 100644 --- a/google/cloud/discoveryengine/v1/internal/schema_stub.h +++ b/google/cloud/discoveryengine/v1/internal/schema_stub.h @@ -83,6 +83,18 @@ class SchemaServiceStub { google::cloud::discoveryengine::v1::DeleteSchemaRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -102,9 +114,13 @@ class DefaultSchemaServiceStub : public SchemaServiceStub { std::unique_ptr< google::cloud::discoveryengine::v1::SchemaService::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr GetSchema( grpc::ClientContext& context, Options const& options, @@ -152,6 +168,18 @@ class DefaultSchemaServiceStub : public SchemaServiceStub { google::cloud::discoveryengine::v1::DeleteSchemaRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -168,6 +196,8 @@ class DefaultSchemaServiceStub : public SchemaServiceStub { std::unique_ptr< google::cloud::discoveryengine::v1::SchemaService::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/discoveryengine/v1/internal/schema_stub_factory.cc b/google/cloud/discoveryengine/v1/internal/schema_stub_factory.cc index 6075d7e423b52..3caf1e2d074e8 100644 --- a/google/cloud/discoveryengine/v1/internal/schema_stub_factory.cc +++ b/google/cloud/discoveryengine/v1/internal/schema_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 CreateDefaultSchemaServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::discoveryengine::v1::SchemaService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/discoveryengine/v1/internal/schema_tracing_connection.cc b/google/cloud/discoveryengine/v1/internal/schema_tracing_connection.cc index a2ada13a7bf93..157ba629ae1e1 100644 --- a/google/cloud/discoveryengine/v1/internal/schema_tracing_connection.cc +++ b/google/cloud/discoveryengine/v1/internal/schema_tracing_connection.cc @@ -138,6 +138,34 @@ SchemaServiceTracingConnection::DeleteSchema( return internal::EndSpan(std::move(span), child_->DeleteSchema(operation)); } +StreamRange +SchemaServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::SchemaServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +SchemaServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::SchemaServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status SchemaServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::SchemaServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/discoveryengine/v1/internal/schema_tracing_connection.h b/google/cloud/discoveryengine/v1/internal/schema_tracing_connection.h index 291d84939310f..a24d8204ab138 100644 --- a/google/cloud/discoveryengine/v1/internal/schema_tracing_connection.h +++ b/google/cloud/discoveryengine/v1/internal/schema_tracing_connection.h @@ -83,6 +83,15 @@ class SchemaServiceTracingConnection future> DeleteSchema(google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/discoveryengine/v1/internal/schema_tracing_stub.cc b/google/cloud/discoveryengine/v1/internal/schema_tracing_stub.cc index bfabd2ea747dc..fba3138c5a9c8 100644 --- a/google/cloud/discoveryengine/v1/internal/schema_tracing_stub.cc +++ b/google/cloud/discoveryengine/v1/internal/schema_tracing_stub.cc @@ -131,6 +131,40 @@ StatusOr SchemaServiceTracingStub::DeleteSchema( child_->DeleteSchema(context, options, request)); } +StatusOr +SchemaServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.SchemaService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr SchemaServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.SchemaService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status SchemaServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.SchemaService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + future> SchemaServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/schema_tracing_stub.h b/google/cloud/discoveryengine/v1/internal/schema_tracing_stub.h index fb7a84cffb67b..00d91f29f4ee4 100644 --- a/google/cloud/discoveryengine/v1/internal/schema_tracing_stub.h +++ b/google/cloud/discoveryengine/v1/internal/schema_tracing_stub.h @@ -84,6 +84,18 @@ class SchemaServiceTracingStub : public SchemaServiceStub { google::cloud::discoveryengine::v1::DeleteSchemaRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/search_auth_decorator.cc b/google/cloud/discoveryengine/v1/internal/search_auth_decorator.cc index ecfa92a4dc8d7..6a00d7e982625 100644 --- a/google/cloud/discoveryengine/v1/internal/search_auth_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/search_auth_decorator.cc @@ -40,6 +40,31 @@ SearchServiceAuth::Search( return child_->Search(context, options, request); } +StatusOr +SearchServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr SearchServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status SearchServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/search_auth_decorator.h b/google/cloud/discoveryengine/v1/internal/search_auth_decorator.h index 6216277216ecf..7ca8d2faa9a4b 100644 --- a/google/cloud/discoveryengine/v1/internal/search_auth_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/search_auth_decorator.h @@ -43,6 +43,18 @@ class SearchServiceAuth : public SearchServiceStub { google::cloud::discoveryengine::v1::SearchRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/discoveryengine/v1/internal/search_connection_impl.cc b/google/cloud/discoveryengine/v1/internal/search_connection_impl.cc index 91361a60bf2ec..d64e34cb85679 100644 --- a/google/cloud/discoveryengine/v1/internal/search_connection_impl.cc +++ b/google/cloud/discoveryengine/v1/internal/search_connection_impl.cc @@ -96,6 +96,66 @@ SearchServiceConnectionImpl::Search( }); } +StreamRange +SearchServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +SearchServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status SearchServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/search_connection_impl.h b/google/cloud/discoveryengine/v1/internal/search_connection_impl.h index cc3c6952bd523..0c08726779f77 100644 --- a/google/cloud/discoveryengine/v1/internal/search_connection_impl.h +++ b/google/cloud/discoveryengine/v1/internal/search_connection_impl.h @@ -52,6 +52,15 @@ class SearchServiceConnectionImpl StreamRange Search(google::cloud::discoveryengine::v1::SearchRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/discoveryengine/v1/internal/search_logging_decorator.cc b/google/cloud/discoveryengine/v1/internal/search_logging_decorator.cc index 4454b0ecc53b4..f170a6330dfc2 100644 --- a/google/cloud/discoveryengine/v1/internal/search_logging_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/search_logging_decorator.cc @@ -47,6 +47,40 @@ SearchServiceLogging::Search( context, options, request, __func__, tracing_options_); } +StatusOr +SearchServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr SearchServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status SearchServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/search_logging_decorator.h b/google/cloud/discoveryengine/v1/internal/search_logging_decorator.h index 5f97734d94f06..942c10ff7555e 100644 --- a/google/cloud/discoveryengine/v1/internal/search_logging_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/search_logging_decorator.h @@ -43,6 +43,18 @@ class SearchServiceLogging : public SearchServiceStub { google::cloud::discoveryengine::v1::SearchRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/discoveryengine/v1/internal/search_metadata_decorator.cc b/google/cloud/discoveryengine/v1/internal/search_metadata_decorator.cc index 56028d3fa6943..b3e824d42f4d7 100644 --- a/google/cloud/discoveryengine/v1/internal/search_metadata_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/search_metadata_decorator.cc @@ -54,6 +54,31 @@ SearchServiceMetadata::Search( return child_->Search(context, options, request); } +StatusOr +SearchServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr SearchServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status SearchServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + void SearchServiceMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/discoveryengine/v1/internal/search_metadata_decorator.h b/google/cloud/discoveryengine/v1/internal/search_metadata_decorator.h index 720144728098c..6a34c76a7030d 100644 --- a/google/cloud/discoveryengine/v1/internal/search_metadata_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/search_metadata_decorator.h @@ -43,6 +43,18 @@ class SearchServiceMetadata : public SearchServiceStub { google::cloud::discoveryengine::v1::SearchRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/discoveryengine/v1/internal/search_stub.cc b/google/cloud/discoveryengine/v1/internal/search_stub.cc index 51fd223cf6899..baa8992d8c42d 100644 --- a/google/cloud/discoveryengine/v1/internal/search_stub.cc +++ b/google/cloud/discoveryengine/v1/internal/search_stub.cc @@ -42,6 +42,40 @@ DefaultSearchServiceStub::Search( return response; } +StatusOr +DefaultSearchServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultSearchServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultSearchServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/search_stub.h b/google/cloud/discoveryengine/v1/internal/search_stub.h index 3fdf351d6460e..22dbd8774b353 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 @@ -38,6 +39,18 @@ class SearchServiceStub { virtual StatusOr Search( grpc::ClientContext& context, Options const& options, google::cloud::discoveryengine::v1::SearchRequest const& request) = 0; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultSearchServiceStub : public SearchServiceStub { @@ -45,18 +58,35 @@ class DefaultSearchServiceStub : public SearchServiceStub { explicit DefaultSearchServiceStub( std::unique_ptr< google::cloud::discoveryengine::v1::SearchService::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr Search( grpc::ClientContext& context, Options const& options, google::cloud::discoveryengine::v1::SearchRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr< google::cloud::discoveryengine::v1::SearchService::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/discoveryengine/v1/internal/search_stub_factory.cc b/google/cloud/discoveryengine/v1/internal/search_stub_factory.cc index 85c4e38c470fa..76617f7cb15e1 100644 --- a/google/cloud/discoveryengine/v1/internal/search_stub_factory.cc +++ b/google/cloud/discoveryengine/v1/internal/search_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 CreateDefaultSearchServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::discoveryengine::v1::SearchService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_stub)); if (auth->RequiresConfigureContext()) { stub = diff --git a/google/cloud/discoveryengine/v1/internal/search_tracing_connection.cc b/google/cloud/discoveryengine/v1/internal/search_tracing_connection.cc index db182f29cc672..9a4afe7dc98e8 100644 --- a/google/cloud/discoveryengine/v1/internal/search_tracing_connection.cc +++ b/google/cloud/discoveryengine/v1/internal/search_tracing_connection.cc @@ -45,6 +45,34 @@ SearchServiceTracingConnection::Search( std::move(span), std::move(sr)); } +StreamRange +SearchServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::SearchServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +SearchServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::SearchServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status SearchServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::SearchServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/discoveryengine/v1/internal/search_tracing_connection.h b/google/cloud/discoveryengine/v1/internal/search_tracing_connection.h index 55c21e74b6793..9b7d04afe66f7 100644 --- a/google/cloud/discoveryengine/v1/internal/search_tracing_connection.h +++ b/google/cloud/discoveryengine/v1/internal/search_tracing_connection.h @@ -43,6 +43,15 @@ class SearchServiceTracingConnection StreamRange Search(google::cloud::discoveryengine::v1::SearchRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/discoveryengine/v1/internal/search_tracing_stub.cc b/google/cloud/discoveryengine/v1/internal/search_tracing_stub.cc index ed27978e08626..3b4231f3ff780 100644 --- a/google/cloud/discoveryengine/v1/internal/search_tracing_stub.cc +++ b/google/cloud/discoveryengine/v1/internal/search_tracing_stub.cc @@ -44,6 +44,40 @@ SearchServiceTracingStub::Search( child_->Search(context, options, request)); } +StatusOr +SearchServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.SearchService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr SearchServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.SearchService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status SearchServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.SearchService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeSearchServiceTracingStub( diff --git a/google/cloud/discoveryengine/v1/internal/search_tracing_stub.h b/google/cloud/discoveryengine/v1/internal/search_tracing_stub.h index c838ce94e9bcf..8e924360447b4 100644 --- a/google/cloud/discoveryengine/v1/internal/search_tracing_stub.h +++ b/google/cloud/discoveryengine/v1/internal/search_tracing_stub.h @@ -43,6 +43,18 @@ class SearchServiceTracingStub : public SearchServiceStub { google::cloud::discoveryengine::v1::SearchRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/discoveryengine/v1/internal/site_search_engine_auth_decorator.cc b/google/cloud/discoveryengine/v1/internal/site_search_engine_auth_decorator.cc index 42c124790ba87..d97313e83daf4 100644 --- a/google/cloud/discoveryengine/v1/internal/site_search_engine_auth_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/site_search_engine_auth_decorator.cc @@ -316,6 +316,32 @@ SiteSearchEngineServiceAuth::FetchDomainVerificationStatus( return child_->FetchDomainVerificationStatus(context, options, request); } +StatusOr +SiteSearchEngineServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +SiteSearchEngineServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status SiteSearchEngineServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + future> SiteSearchEngineServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/site_search_engine_auth_decorator.h b/google/cloud/discoveryengine/v1/internal/site_search_engine_auth_decorator.h index fdfd43f1d866b..8c8258cd1e2bf 100644 --- a/google/cloud/discoveryengine/v1/internal/site_search_engine_auth_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/site_search_engine_auth_decorator.h @@ -161,6 +161,18 @@ class SiteSearchEngineServiceAuth : public SiteSearchEngineServiceStub { google::cloud::discoveryengine::v1:: FetchDomainVerificationStatusRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/site_search_engine_connection_impl.cc b/google/cloud/discoveryengine/v1/internal/site_search_engine_connection_impl.cc index 7520714f9684f..622817a706741 100644 --- a/google/cloud/discoveryengine/v1/internal/site_search_engine_connection_impl.cc +++ b/google/cloud/discoveryengine/v1/internal/site_search_engine_connection_impl.cc @@ -952,6 +952,67 @@ SiteSearchEngineServiceConnectionImpl::FetchDomainVerificationStatus( }); } +StreamRange +SiteSearchEngineServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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< + discoveryengine_v1::SiteSearchEngineServiceRetryPolicy>( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +SiteSearchEngineServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status SiteSearchEngineServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/site_search_engine_connection_impl.h b/google/cloud/discoveryengine/v1/internal/site_search_engine_connection_impl.h index abdf728fed894..84360fcd388d9 100644 --- a/google/cloud/discoveryengine/v1/internal/site_search_engine_connection_impl.h +++ b/google/cloud/discoveryengine/v1/internal/site_search_engine_connection_impl.h @@ -185,6 +185,15 @@ class SiteSearchEngineServiceConnectionImpl google::cloud::discoveryengine::v1::FetchDomainVerificationStatusRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr diff --git a/google/cloud/discoveryengine/v1/internal/site_search_engine_logging_decorator.cc b/google/cloud/discoveryengine/v1/internal/site_search_engine_logging_decorator.cc index 7820ea10358aa..b87e132a6ff19 100644 --- a/google/cloud/discoveryengine/v1/internal/site_search_engine_logging_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/site_search_engine_logging_decorator.cc @@ -361,6 +361,41 @@ SiteSearchEngineServiceLogging::FetchDomainVerificationStatus( context, options, request, __func__, tracing_options_); } +StatusOr +SiteSearchEngineServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +SiteSearchEngineServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status SiteSearchEngineServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> SiteSearchEngineServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/site_search_engine_logging_decorator.h b/google/cloud/discoveryengine/v1/internal/site_search_engine_logging_decorator.h index f6f4642907b8b..2e6ad0257b196 100644 --- a/google/cloud/discoveryengine/v1/internal/site_search_engine_logging_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/site_search_engine_logging_decorator.h @@ -161,6 +161,18 @@ class SiteSearchEngineServiceLogging : public SiteSearchEngineServiceStub { google::cloud::discoveryengine::v1:: FetchDomainVerificationStatusRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/site_search_engine_metadata_decorator.cc b/google/cloud/discoveryengine/v1/internal/site_search_engine_metadata_decorator.cc index e4af89a9afd18..270525697ae7a 100644 --- a/google/cloud/discoveryengine/v1/internal/site_search_engine_metadata_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/site_search_engine_metadata_decorator.cc @@ -274,6 +274,32 @@ SiteSearchEngineServiceMetadata::FetchDomainVerificationStatus( return child_->FetchDomainVerificationStatus(context, options, request); } +StatusOr +SiteSearchEngineServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +SiteSearchEngineServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status SiteSearchEngineServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + future> SiteSearchEngineServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/site_search_engine_metadata_decorator.h b/google/cloud/discoveryengine/v1/internal/site_search_engine_metadata_decorator.h index 8f4cc02ad0f71..b21fe65d28886 100644 --- a/google/cloud/discoveryengine/v1/internal/site_search_engine_metadata_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/site_search_engine_metadata_decorator.h @@ -162,6 +162,18 @@ class SiteSearchEngineServiceMetadata : public SiteSearchEngineServiceStub { google::cloud::discoveryengine::v1:: FetchDomainVerificationStatusRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/site_search_engine_stub.cc b/google/cloud/discoveryengine/v1/internal/site_search_engine_stub.cc index d97adf9d4928f..0f7abae18f4f7 100644 --- a/google/cloud/discoveryengine/v1/internal/site_search_engine_stub.cc +++ b/google/cloud/discoveryengine/v1/internal/site_search_engine_stub.cc @@ -350,6 +350,41 @@ DefaultSiteSearchEngineServiceStub::FetchDomainVerificationStatus( return response; } +StatusOr +DefaultSiteSearchEngineServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultSiteSearchEngineServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultSiteSearchEngineServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + future> DefaultSiteSearchEngineServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, 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..2c02c3769b980 100644 --- a/google/cloud/discoveryengine/v1/internal/site_search_engine_stub.h +++ b/google/cloud/discoveryengine/v1/internal/site_search_engine_stub.h @@ -165,6 +165,18 @@ class SiteSearchEngineServiceStub { google::cloud::discoveryengine::v1:: FetchDomainVerificationStatusRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -184,9 +196,13 @@ class DefaultSiteSearchEngineServiceStub : public SiteSearchEngineServiceStub { std::unique_ptr grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr GetSiteSearchEngine( @@ -310,6 +326,18 @@ class DefaultSiteSearchEngineServiceStub : public SiteSearchEngineServiceStub { google::cloud::discoveryengine::v1:: FetchDomainVerificationStatusRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -326,6 +354,8 @@ class DefaultSiteSearchEngineServiceStub : public SiteSearchEngineServiceStub { std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/discoveryengine/v1/internal/site_search_engine_stub_factory.cc b/google/cloud/discoveryengine/v1/internal/site_search_engine_stub_factory.cc index 3210e49fe4167..3012a518cb1e6 100644 --- a/google/cloud/discoveryengine/v1/internal/site_search_engine_stub_factory.cc +++ b/google/cloud/discoveryengine/v1/internal/site_search_engine_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 @@ CreateDefaultSiteSearchEngineServiceStub( auto service_grpc_stub = google::cloud::discoveryengine::v1::SiteSearchEngineService::NewStub( channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/discoveryengine/v1/internal/site_search_engine_tracing_connection.cc b/google/cloud/discoveryengine/v1/internal/site_search_engine_tracing_connection.cc index 6c5722ff037f5..126bb6203bb23 100644 --- a/google/cloud/discoveryengine/v1/internal/site_search_engine_tracing_connection.cc +++ b/google/cloud/discoveryengine/v1/internal/site_search_engine_tracing_connection.cc @@ -366,6 +366,34 @@ SiteSearchEngineServiceTracingConnection::FetchDomainVerificationStatus( std::move(sr)); } +StreamRange +SiteSearchEngineServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::SiteSearchEngineServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +SiteSearchEngineServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::SiteSearchEngineServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status SiteSearchEngineServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::SiteSearchEngineServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/discoveryengine/v1/internal/site_search_engine_tracing_connection.h b/google/cloud/discoveryengine/v1/internal/site_search_engine_tracing_connection.h index 765c5df7eba77..3abf333540e80 100644 --- a/google/cloud/discoveryengine/v1/internal/site_search_engine_tracing_connection.h +++ b/google/cloud/discoveryengine/v1/internal/site_search_engine_tracing_connection.h @@ -173,6 +173,15 @@ class SiteSearchEngineServiceTracingConnection google::cloud::discoveryengine::v1::FetchDomainVerificationStatusRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/discoveryengine/v1/internal/site_search_engine_tracing_stub.cc b/google/cloud/discoveryengine/v1/internal/site_search_engine_tracing_stub.cc index 81f4d4402158c..e15351a63d1e7 100644 --- a/google/cloud/discoveryengine/v1/internal/site_search_engine_tracing_stub.cc +++ b/google/cloud/discoveryengine/v1/internal/site_search_engine_tracing_stub.cc @@ -335,6 +335,44 @@ SiteSearchEngineServiceTracingStub::FetchDomainVerificationStatus( child_->FetchDomainVerificationStatus(context, options, request)); } +StatusOr +SiteSearchEngineServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.SiteSearchEngineService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +SiteSearchEngineServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.SiteSearchEngineService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status SiteSearchEngineServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.SiteSearchEngineService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + future> SiteSearchEngineServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/site_search_engine_tracing_stub.h b/google/cloud/discoveryengine/v1/internal/site_search_engine_tracing_stub.h index bb0b78e9bbe49..3241cadb8b765 100644 --- a/google/cloud/discoveryengine/v1/internal/site_search_engine_tracing_stub.h +++ b/google/cloud/discoveryengine/v1/internal/site_search_engine_tracing_stub.h @@ -161,6 +161,18 @@ class SiteSearchEngineServiceTracingStub : public SiteSearchEngineServiceStub { google::cloud::discoveryengine::v1:: FetchDomainVerificationStatusRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/user_event_auth_decorator.cc b/google/cloud/discoveryengine/v1/internal/user_event_auth_decorator.cc index f794cdbe8cfb0..5829bc5bb5ae1 100644 --- a/google/cloud/discoveryengine/v1/internal/user_event_auth_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/user_event_auth_decorator.cc @@ -79,6 +79,31 @@ StatusOr UserEventServiceAuth::ImportUserEvents( return child_->ImportUserEvents(context, options, request); } +StatusOr +UserEventServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr UserEventServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status UserEventServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + future> UserEventServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/user_event_auth_decorator.h b/google/cloud/discoveryengine/v1/internal/user_event_auth_decorator.h index 700e95c84192c..fe08daa325b28 100644 --- a/google/cloud/discoveryengine/v1/internal/user_event_auth_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/user_event_auth_decorator.h @@ -61,6 +61,18 @@ class UserEventServiceAuth : public UserEventServiceStub { google::cloud::discoveryengine::v1::ImportUserEventsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/user_event_connection_impl.cc b/google/cloud/discoveryengine/v1/internal/user_event_connection_impl.cc index 27e2616d3a500..380e11db182b2 100644 --- a/google/cloud/discoveryengine/v1/internal/user_event_connection_impl.cc +++ b/google/cloud/discoveryengine/v1/internal/user_event_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 @@ -194,6 +195,66 @@ UserEventServiceConnectionImpl::ImportUserEvents( polling_policy(*current), __func__); } +StreamRange +UserEventServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +UserEventServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status UserEventServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1_internal } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/internal/user_event_connection_impl.h b/google/cloud/discoveryengine/v1/internal/user_event_connection_impl.h index 524b796b6d1dc..b57f26ee09160 100644 --- a/google/cloud/discoveryengine/v1/internal/user_event_connection_impl.h +++ b/google/cloud/discoveryengine/v1/internal/user_event_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 @@ -72,6 +73,15 @@ class UserEventServiceConnectionImpl future> ImportUserEvents(google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/discoveryengine/v1/internal/user_event_logging_decorator.cc b/google/cloud/discoveryengine/v1/internal/user_event_logging_decorator.cc index 95b41beb108f3..84ae5d4054c65 100644 --- a/google/cloud/discoveryengine/v1/internal/user_event_logging_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/user_event_logging_decorator.cc @@ -95,6 +95,40 @@ UserEventServiceLogging::ImportUserEvents( context, options, request, __func__, tracing_options_); } +StatusOr +UserEventServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr UserEventServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status UserEventServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> UserEventServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/user_event_logging_decorator.h b/google/cloud/discoveryengine/v1/internal/user_event_logging_decorator.h index e03e7d3edf1da..6b0b701c64e4d 100644 --- a/google/cloud/discoveryengine/v1/internal/user_event_logging_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/user_event_logging_decorator.h @@ -61,6 +61,18 @@ class UserEventServiceLogging : public UserEventServiceStub { google::cloud::discoveryengine::v1::ImportUserEventsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/user_event_metadata_decorator.cc b/google/cloud/discoveryengine/v1/internal/user_event_metadata_decorator.cc index 146297768ac5d..e9cc3c95e725b 100644 --- a/google/cloud/discoveryengine/v1/internal/user_event_metadata_decorator.cc +++ b/google/cloud/discoveryengine/v1/internal/user_event_metadata_decorator.cc @@ -85,6 +85,31 @@ UserEventServiceMetadata::ImportUserEvents( return child_->ImportUserEvents(context, options, request); } +StatusOr +UserEventServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr UserEventServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status UserEventServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + future> UserEventServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/user_event_metadata_decorator.h b/google/cloud/discoveryengine/v1/internal/user_event_metadata_decorator.h index 78b27386bffde..c0804993637e9 100644 --- a/google/cloud/discoveryengine/v1/internal/user_event_metadata_decorator.h +++ b/google/cloud/discoveryengine/v1/internal/user_event_metadata_decorator.h @@ -62,6 +62,18 @@ class UserEventServiceMetadata : public UserEventServiceStub { google::cloud::discoveryengine::v1::ImportUserEventsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/internal/user_event_stub.cc b/google/cloud/discoveryengine/v1/internal/user_event_stub.cc index 6af5e28051505..28ff94f6c729c 100644 --- a/google/cloud/discoveryengine/v1/internal/user_event_stub.cc +++ b/google/cloud/discoveryengine/v1/internal/user_event_stub.cc @@ -88,6 +88,41 @@ DefaultUserEventServiceStub::ImportUserEvents( return response; } +StatusOr +DefaultUserEventServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultUserEventServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultUserEventServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + future> DefaultUserEventServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/user_event_stub.h b/google/cloud/discoveryengine/v1/internal/user_event_stub.h index 63a23ccae3ba4..0ed960fe0547d 100644 --- a/google/cloud/discoveryengine/v1/internal/user_event_stub.h +++ b/google/cloud/discoveryengine/v1/internal/user_event_stub.h @@ -62,6 +62,18 @@ class UserEventServiceStub { google::cloud::discoveryengine::v1::ImportUserEventsRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -81,9 +93,13 @@ class DefaultUserEventServiceStub : public UserEventServiceStub { std::unique_ptr< google::cloud::discoveryengine::v1::UserEventService::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr WriteUserEvent( grpc::ClientContext& context, Options const& options, @@ -107,6 +123,18 @@ class DefaultUserEventServiceStub : public UserEventServiceStub { google::cloud::discoveryengine::v1::ImportUserEventsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -123,6 +151,8 @@ class DefaultUserEventServiceStub : public UserEventServiceStub { std::unique_ptr< google::cloud::discoveryengine::v1::UserEventService::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/discoveryengine/v1/internal/user_event_stub_factory.cc b/google/cloud/discoveryengine/v1/internal/user_event_stub_factory.cc index 3d66533b20e8a..0911f885126fd 100644 --- a/google/cloud/discoveryengine/v1/internal/user_event_stub_factory.cc +++ b/google/cloud/discoveryengine/v1/internal/user_event_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 CreateDefaultUserEventServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::discoveryengine::v1::UserEventService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/discoveryengine/v1/internal/user_event_tracing_connection.cc b/google/cloud/discoveryengine/v1/internal/user_event_tracing_connection.cc index a3953ba1424b6..9f91031d51b7f 100644 --- a/google/cloud/discoveryengine/v1/internal/user_event_tracing_connection.cc +++ b/google/cloud/discoveryengine/v1/internal/user_event_tracing_connection.cc @@ -18,6 +18,7 @@ #include "google/cloud/discoveryengine/v1/internal/user_event_tracing_connection.h" #include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" #include #include @@ -83,6 +84,34 @@ UserEventServiceTracingConnection::ImportUserEvents( child_->ImportUserEvents(operation)); } +StreamRange +UserEventServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::UserEventServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +UserEventServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::UserEventServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status UserEventServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "discoveryengine_v1::UserEventServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/discoveryengine/v1/internal/user_event_tracing_connection.h b/google/cloud/discoveryengine/v1/internal/user_event_tracing_connection.h index 223f390292897..dfe110e99baf1 100644 --- a/google/cloud/discoveryengine/v1/internal/user_event_tracing_connection.h +++ b/google/cloud/discoveryengine/v1/internal/user_event_tracing_connection.h @@ -61,6 +61,15 @@ class UserEventServiceTracingConnection future> ImportUserEvents(google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/discoveryengine/v1/internal/user_event_tracing_stub.cc b/google/cloud/discoveryengine/v1/internal/user_event_tracing_stub.cc index 35ba0e6019e7a..83e5b21689784 100644 --- a/google/cloud/discoveryengine/v1/internal/user_event_tracing_stub.cc +++ b/google/cloud/discoveryengine/v1/internal/user_event_tracing_stub.cc @@ -85,6 +85,41 @@ UserEventServiceTracingStub::ImportUserEvents( child_->ImportUserEvents(context, options, request)); } +StatusOr +UserEventServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.UserEventService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +UserEventServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.UserEventService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status UserEventServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.discoveryengine.v1.UserEventService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + future> UserEventServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/discoveryengine/v1/internal/user_event_tracing_stub.h b/google/cloud/discoveryengine/v1/internal/user_event_tracing_stub.h index 9294e562844f2..33e01ce3e8134 100644 --- a/google/cloud/discoveryengine/v1/internal/user_event_tracing_stub.h +++ b/google/cloud/discoveryengine/v1/internal/user_event_tracing_stub.h @@ -61,6 +61,18 @@ class UserEventServiceTracingStub : public UserEventServiceStub { google::cloud::discoveryengine::v1::ImportUserEventsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/discoveryengine/v1/mocks/mock_completion_connection.h b/google/cloud/discoveryengine/v1/mocks/mock_completion_connection.h index bfd2db53ee783..1a8f3b843d9c5 100644 --- a/google/cloud/discoveryengine/v1/mocks/mock_completion_connection.h +++ b/google/cloud/discoveryengine/v1/mocks/mock_completion_connection.h @@ -224,6 +224,17 @@ class MockCompletionServiceConnection PurgeCompletionSuggestionsResponse>>, PurgeCompletionSuggestions, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/discoveryengine/v1/mocks/mock_control_connection.h b/google/cloud/discoveryengine/v1/mocks/mock_control_connection.h index f6721cde72786..83119434c04b0 100644 --- a/google/cloud/discoveryengine/v1/mocks/mock_control_connection.h +++ b/google/cloud/discoveryengine/v1/mocks/mock_control_connection.h @@ -71,6 +71,17 @@ class MockControlServiceConnection ListControls, (google::cloud::discoveryengine::v1::ListControlsRequest request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/discoveryengine/v1/mocks/mock_conversational_search_connection.h b/google/cloud/discoveryengine/v1/mocks/mock_conversational_search_connection.h index 5f74fcd465466..afa4e9eb635a8 100644 --- a/google/cloud/discoveryengine/v1/mocks/mock_conversational_search_connection.h +++ b/google/cloud/discoveryengine/v1/mocks/mock_conversational_search_connection.h @@ -122,6 +122,17 @@ class MockConversationalSearchServiceConnection ListSessions, (google::cloud::discoveryengine::v1::ListSessionsRequest request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/discoveryengine/v1/mocks/mock_data_store_connection.h b/google/cloud/discoveryengine/v1/mocks/mock_data_store_connection.h index e304df4469415..d1ff2be0abdd2 100644 --- a/google/cloud/discoveryengine/v1/mocks/mock_data_store_connection.h +++ b/google/cloud/discoveryengine/v1/mocks/mock_data_store_connection.h @@ -143,6 +143,17 @@ class MockDataStoreServiceConnection (google::cloud::discoveryengine::v1::UpdateDataStoreRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/discoveryengine/v1/mocks/mock_document_connection.h b/google/cloud/discoveryengine/v1/mocks/mock_document_connection.h index 29fb2cc49d4ab..0f328a93bce41 100644 --- a/google/cloud/discoveryengine/v1/mocks/mock_document_connection.h +++ b/google/cloud/discoveryengine/v1/mocks/mock_document_connection.h @@ -158,6 +158,17 @@ class MockDocumentServiceConnection StatusOr>, PurgeDocuments, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/discoveryengine/v1/mocks/mock_engine_connection.h b/google/cloud/discoveryengine/v1/mocks/mock_engine_connection.h index b55fe8fff45a2..35c2310343828 100644 --- a/google/cloud/discoveryengine/v1/mocks/mock_engine_connection.h +++ b/google/cloud/discoveryengine/v1/mocks/mock_engine_connection.h @@ -142,6 +142,17 @@ class MockEngineServiceConnection ListEngines, (google::cloud::discoveryengine::v1::ListEnginesRequest request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/discoveryengine/v1/mocks/mock_grounded_generation_connection.h b/google/cloud/discoveryengine/v1/mocks/mock_grounded_generation_connection.h index 1f14345a5b2b8..022f979321a6e 100644 --- a/google/cloud/discoveryengine/v1/mocks/mock_grounded_generation_connection.h +++ b/google/cloud/discoveryengine/v1/mocks/mock_grounded_generation_connection.h @@ -53,6 +53,17 @@ class MockGroundedGenerationServiceConnection (google::cloud::discoveryengine::v1::CheckGroundingRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/discoveryengine/v1/mocks/mock_project_connection.h b/google/cloud/discoveryengine/v1/mocks/mock_project_connection.h index df7a8c4b520c4..c6e16418ac91e 100644 --- a/google/cloud/discoveryengine/v1/mocks/mock_project_connection.h +++ b/google/cloud/discoveryengine/v1/mocks/mock_project_connection.h @@ -87,6 +87,17 @@ class MockProjectServiceConnection MOCK_METHOD(future>, ProvisionProject, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/discoveryengine/v1/mocks/mock_rank_connection.h b/google/cloud/discoveryengine/v1/mocks/mock_rank_connection.h index 37487bd0d1902..1e700e9a05cde 100644 --- a/google/cloud/discoveryengine/v1/mocks/mock_rank_connection.h +++ b/google/cloud/discoveryengine/v1/mocks/mock_rank_connection.h @@ -50,6 +50,17 @@ class MockRankServiceConnection MOCK_METHOD(StatusOr, Rank, (google::cloud::discoveryengine::v1::RankRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/discoveryengine/v1/mocks/mock_recommendation_connection.h b/google/cloud/discoveryengine/v1/mocks/mock_recommendation_connection.h index 6d607f09d648f..1141e0647ec83 100644 --- a/google/cloud/discoveryengine/v1/mocks/mock_recommendation_connection.h +++ b/google/cloud/discoveryengine/v1/mocks/mock_recommendation_connection.h @@ -52,6 +52,17 @@ class MockRecommendationServiceConnection Recommend, (google::cloud::discoveryengine::v1::RecommendRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/discoveryengine/v1/mocks/mock_schema_connection.h b/google/cloud/discoveryengine/v1/mocks/mock_schema_connection.h index cd7b6abd9e656..4c23f6481a011 100644 --- a/google/cloud/discoveryengine/v1/mocks/mock_schema_connection.h +++ b/google/cloud/discoveryengine/v1/mocks/mock_schema_connection.h @@ -176,6 +176,17 @@ class MockSchemaServiceConnection StatusOr>, DeleteSchema, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/discoveryengine/v1/mocks/mock_search_connection.h b/google/cloud/discoveryengine/v1/mocks/mock_search_connection.h index a000a7374751d..39208f4e2c3e3 100644 --- a/google/cloud/discoveryengine/v1/mocks/mock_search_connection.h +++ b/google/cloud/discoveryengine/v1/mocks/mock_search_connection.h @@ -52,6 +52,17 @@ class MockSearchServiceConnection google::cloud::discoveryengine::v1::SearchResponse::SearchResult>), Search, (google::cloud::discoveryengine::v1::SearchRequest request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/discoveryengine/v1/mocks/mock_site_search_engine_connection.h b/google/cloud/discoveryengine/v1/mocks/mock_site_search_engine_connection.h index 961dbd09115d3..7b78126af12e8 100644 --- a/google/cloud/discoveryengine/v1/mocks/mock_site_search_engine_connection.h +++ b/google/cloud/discoveryengine/v1/mocks/mock_site_search_engine_connection.h @@ -409,6 +409,17 @@ class MockSiteSearchEngineServiceConnection (google::cloud::discoveryengine::v1::FetchDomainVerificationStatusRequest request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/discoveryengine/v1/mocks/mock_user_event_connection.h b/google/cloud/discoveryengine/v1/mocks/mock_user_event_connection.h index 9a0d9a8af7488..3ee5767b10e59 100644 --- a/google/cloud/discoveryengine/v1/mocks/mock_user_event_connection.h +++ b/google/cloud/discoveryengine/v1/mocks/mock_user_event_connection.h @@ -102,6 +102,17 @@ class MockUserEventServiceConnection google::cloud::discoveryengine::v1::ImportUserEventsResponse>>, ImportUserEvents, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/discoveryengine/v1/project_client.cc b/google/cloud/discoveryengine/v1/project_client.cc index 1f072923d8291..4ad6350b75704 100644 --- a/google/cloud/discoveryengine/v1/project_client.cc +++ b/google/cloud/discoveryengine/v1/project_client.cc @@ -71,6 +71,51 @@ ProjectServiceClient::ProvisionProject( return connection_->ProvisionProject(operation); } +StreamRange +ProjectServiceClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +ProjectServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr ProjectServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr ProjectServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status ProjectServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status ProjectServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1 } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/project_client.h b/google/cloud/discoveryengine/v1/project_client.h index 85e967342935d..5779e8b8ae0af 100644 --- a/google/cloud/discoveryengine/v1/project_client.h +++ b/google/cloud/discoveryengine/v1/project_client.h @@ -219,6 +219,231 @@ class ProjectServiceClient { ProvisionProject(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/discoveryengine/v1/project_connection.cc b/google/cloud/discoveryengine/v1/project_connection.cc index 314beddaeee6b..01867645affb2 100644 --- a/google/cloud/discoveryengine/v1/project_connection.cc +++ b/google/cloud/discoveryengine/v1/project_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 @@ -61,6 +62,24 @@ ProjectServiceConnection::ProvisionProject( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +ProjectServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr ProjectServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ProjectServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeProjectServiceConnection( Options options) { internal::CheckExpectedOptions #include @@ -197,6 +198,15 @@ class ProjectServiceConnection { virtual future> ProvisionProject(google::longrunning::Operation const& operation); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/discoveryengine/v1/project_connection_idempotency_policy.cc b/google/cloud/discoveryengine/v1/project_connection_idempotency_policy.cc index 5242f7cd5d0bc..5fb3747a2ebf8 100644 --- a/google/cloud/discoveryengine/v1/project_connection_idempotency_policy.cc +++ b/google/cloud/discoveryengine/v1/project_connection_idempotency_policy.cc @@ -39,6 +39,21 @@ Idempotency ProjectServiceConnectionIdempotencyPolicy::ProvisionProject( return Idempotency::kNonIdempotent; } +Idempotency ProjectServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ProjectServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ProjectServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultProjectServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/discoveryengine/v1/project_connection_idempotency_policy.h b/google/cloud/discoveryengine/v1/project_connection_idempotency_policy.h index 2d2b93317b2dd..f23a997ef84f0 100644 --- a/google/cloud/discoveryengine/v1/project_connection_idempotency_policy.h +++ b/google/cloud/discoveryengine/v1/project_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -40,6 +41,15 @@ class ProjectServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ProvisionProject( google::cloud::discoveryengine::v1::ProvisionProjectRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/discoveryengine/v1/rank_client.cc b/google/cloud/discoveryengine/v1/rank_client.cc index 5ff71a36bb288..5c5978939b944 100644 --- a/google/cloud/discoveryengine/v1/rank_client.cc +++ b/google/cloud/discoveryengine/v1/rank_client.cc @@ -40,6 +40,49 @@ RankServiceClient::Rank( return connection_->Rank(request); } +StreamRange RankServiceClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange RankServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr RankServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr RankServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status RankServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status RankServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1 } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/rank_client.h b/google/cloud/discoveryengine/v1/rank_client.h index 17d5890fd4f08..6d2c324f4d021 100644 --- a/google/cloud/discoveryengine/v1/rank_client.h +++ b/google/cloud/discoveryengine/v1/rank_client.h @@ -117,6 +117,231 @@ class RankServiceClient { google::cloud::discoveryengine::v1::RankRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/discoveryengine/v1/rank_connection.cc b/google/cloud/discoveryengine/v1/rank_connection.cc index caf5880cfa738..bd03185125878 100644 --- a/google/cloud/discoveryengine/v1/rank_connection.cc +++ b/google/cloud/discoveryengine/v1/rank_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,24 @@ RankServiceConnection::Rank( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +RankServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr RankServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status RankServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeRankServiceConnection( Options options) { internal::CheckExpectedOptions #include @@ -182,6 +183,15 @@ class RankServiceConnection { virtual StatusOr Rank( google::cloud::discoveryengine::v1::RankRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/discoveryengine/v1/rank_connection_idempotency_policy.cc b/google/cloud/discoveryengine/v1/rank_connection_idempotency_policy.cc index 451b99d3e4de0..3cce649004a69 100644 --- a/google/cloud/discoveryengine/v1/rank_connection_idempotency_policy.cc +++ b/google/cloud/discoveryengine/v1/rank_connection_idempotency_policy.cc @@ -39,6 +39,21 @@ Idempotency RankServiceConnectionIdempotencyPolicy::Rank( return Idempotency::kNonIdempotent; } +Idempotency RankServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency RankServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency RankServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultRankServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/discoveryengine/v1/rank_connection_idempotency_policy.h b/google/cloud/discoveryengine/v1/rank_connection_idempotency_policy.h index 6e0dab7a7463a..e7dee987bb412 100644 --- a/google/cloud/discoveryengine/v1/rank_connection_idempotency_policy.h +++ b/google/cloud/discoveryengine/v1/rank_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,15 @@ class RankServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency Rank( google::cloud::discoveryengine::v1::RankRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/discoveryengine/v1/recommendation_client.cc b/google/cloud/discoveryengine/v1/recommendation_client.cc index 5254817634930..491aff226b9af 100644 --- a/google/cloud/discoveryengine/v1/recommendation_client.cc +++ b/google/cloud/discoveryengine/v1/recommendation_client.cc @@ -40,6 +40,54 @@ RecommendationServiceClient::Recommend( return connection_->Recommend(request); } +StreamRange +RecommendationServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +RecommendationServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +RecommendationServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +RecommendationServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status RecommendationServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status RecommendationServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1 } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/recommendation_client.h b/google/cloud/discoveryengine/v1/recommendation_client.h index 0088eac37df4f..ad8a30b9cd5ca 100644 --- a/google/cloud/discoveryengine/v1/recommendation_client.h +++ b/google/cloud/discoveryengine/v1/recommendation_client.h @@ -120,6 +120,231 @@ class RecommendationServiceClient { google::cloud::discoveryengine::v1::RecommendRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/discoveryengine/v1/recommendation_connection.cc b/google/cloud/discoveryengine/v1/recommendation_connection.cc index ba341d4098cd1..77ba59fcafb91 100644 --- a/google/cloud/discoveryengine/v1/recommendation_connection.cc +++ b/google/cloud/discoveryengine/v1/recommendation_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,25 @@ RecommendationServiceConnection::Recommend( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +RecommendationServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +RecommendationServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status RecommendationServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeRecommendationServiceConnection(Options options) { internal::CheckExpectedOptions #include @@ -191,6 +192,15 @@ class RecommendationServiceConnection { virtual StatusOr Recommend( google::cloud::discoveryengine::v1::RecommendRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/discoveryengine/v1/recommendation_connection_idempotency_policy.cc b/google/cloud/discoveryengine/v1/recommendation_connection_idempotency_policy.cc index 69ec16187ca76..3a4a3cec3c578 100644 --- a/google/cloud/discoveryengine/v1/recommendation_connection_idempotency_policy.cc +++ b/google/cloud/discoveryengine/v1/recommendation_connection_idempotency_policy.cc @@ -40,6 +40,21 @@ Idempotency RecommendationServiceConnectionIdempotencyPolicy::Recommend( return Idempotency::kNonIdempotent; } +Idempotency RecommendationServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency RecommendationServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency RecommendationServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultRecommendationServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/discoveryengine/v1/recommendation_connection_idempotency_policy.h b/google/cloud/discoveryengine/v1/recommendation_connection_idempotency_policy.h index da55dc619bf7d..e09ce0d7ecc3a 100644 --- a/google/cloud/discoveryengine/v1/recommendation_connection_idempotency_policy.h +++ b/google/cloud/discoveryengine/v1/recommendation_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -39,6 +40,15 @@ class RecommendationServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency Recommend( google::cloud::discoveryengine::v1::RecommendRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/discoveryengine/v1/schema_client.cc b/google/cloud/discoveryengine/v1/schema_client.cc index 89bd801caada4..e743bfc410a5a 100644 --- a/google/cloud/discoveryengine/v1/schema_client.cc +++ b/google/cloud/discoveryengine/v1/schema_client.cc @@ -174,6 +174,49 @@ SchemaServiceClient::DeleteSchema( return connection_->DeleteSchema(operation); } +StreamRange SchemaServiceClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange SchemaServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr SchemaServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr SchemaServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status SchemaServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status SchemaServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1 } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/schema_client.h b/google/cloud/discoveryengine/v1/schema_client.h index 41edf173426a6..027ef0be1176c 100644 --- a/google/cloud/discoveryengine/v1/schema_client.h +++ b/google/cloud/discoveryengine/v1/schema_client.h @@ -533,6 +533,231 @@ class SchemaServiceClient { DeleteSchema(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/discoveryengine/v1/schema_connection.cc b/google/cloud/discoveryengine/v1/schema_connection.cc index b1aca7623b209..bd58af03c88d2 100644 --- a/google/cloud/discoveryengine/v1/schema_connection.cc +++ b/google/cloud/discoveryengine/v1/schema_connection.cc @@ -118,6 +118,24 @@ SchemaServiceConnection::DeleteSchema(google::longrunning::Operation const&) { Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +SchemaServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr SchemaServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status SchemaServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSchemaServiceConnection( Options options) { internal::CheckExpectedOptions> DeleteSchema(google::longrunning::Operation const& operation); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/discoveryengine/v1/schema_connection_idempotency_policy.cc b/google/cloud/discoveryengine/v1/schema_connection_idempotency_policy.cc index 7b3e6d5e8c127..bd1c6b1dcf6a1 100644 --- a/google/cloud/discoveryengine/v1/schema_connection_idempotency_policy.cc +++ b/google/cloud/discoveryengine/v1/schema_connection_idempotency_policy.cc @@ -59,6 +59,21 @@ Idempotency SchemaServiceConnectionIdempotencyPolicy::DeleteSchema( return Idempotency::kNonIdempotent; } +Idempotency SchemaServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SchemaServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency SchemaServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultSchemaServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/discoveryengine/v1/schema_connection_idempotency_policy.h b/google/cloud/discoveryengine/v1/schema_connection_idempotency_policy.h index 8cd112b262415..6ed0d0d34c6a2 100644 --- a/google/cloud/discoveryengine/v1/schema_connection_idempotency_policy.h +++ b/google/cloud/discoveryengine/v1/schema_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 SchemaServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteSchema( google::cloud::discoveryengine::v1::DeleteSchemaRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/discoveryengine/v1/search_client.cc b/google/cloud/discoveryengine/v1/search_client.cc index cfa4d2d943ca2..4010ced0f0039 100644 --- a/google/cloud/discoveryengine/v1/search_client.cc +++ b/google/cloud/discoveryengine/v1/search_client.cc @@ -39,6 +39,49 @@ SearchServiceClient::Search( return connection_->Search(std::move(request)); } +StreamRange SearchServiceClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange SearchServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr SearchServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr SearchServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status SearchServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status SearchServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1 } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/search_client.h b/google/cloud/discoveryengine/v1/search_client.h index 144e1b1d9976b..1d75a147f5c17 100644 --- a/google/cloud/discoveryengine/v1/search_client.h +++ b/google/cloud/discoveryengine/v1/search_client.h @@ -126,6 +126,231 @@ class SearchServiceClient { Search(google::cloud::discoveryengine::v1::SearchRequest request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/discoveryengine/v1/search_connection.cc b/google/cloud/discoveryengine/v1/search_connection.cc index 4979916e86bdf..5e7b71875ea80 100644 --- a/google/cloud/discoveryengine/v1/search_connection.cc +++ b/google/cloud/discoveryengine/v1/search_connection.cc @@ -46,6 +46,24 @@ SearchServiceConnection::Search( google::cloud::discoveryengine::v1::SearchResponse::SearchResult>>(); } +StreamRange +SearchServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr SearchServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status SearchServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSearchServiceConnection( Options options) { internal::CheckExpectedOptions Search(google::cloud::discoveryengine::v1::SearchRequest request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/discoveryengine/v1/search_connection_idempotency_policy.cc b/google/cloud/discoveryengine/v1/search_connection_idempotency_policy.cc index e51a7457ca486..a90120b5036f9 100644 --- a/google/cloud/discoveryengine/v1/search_connection_idempotency_policy.cc +++ b/google/cloud/discoveryengine/v1/search_connection_idempotency_policy.cc @@ -39,6 +39,21 @@ Idempotency SearchServiceConnectionIdempotencyPolicy::Search( return Idempotency::kNonIdempotent; } +Idempotency SearchServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SearchServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency SearchServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultSearchServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/discoveryengine/v1/search_connection_idempotency_policy.h b/google/cloud/discoveryengine/v1/search_connection_idempotency_policy.h index c3bc4cd5b0fd1..6810036d83315 100644 --- a/google/cloud/discoveryengine/v1/search_connection_idempotency_policy.h +++ b/google/cloud/discoveryengine/v1/search_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -39,6 +40,15 @@ class SearchServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency Search( google::cloud::discoveryengine::v1::SearchRequest request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/discoveryengine/v1/site_search_engine_client.cc b/google/cloud/discoveryengine/v1/site_search_engine_client.cc index d9f08c6f5a4a6..d9c2d68db9a65 100644 --- a/google/cloud/discoveryengine/v1/site_search_engine_client.cc +++ b/google/cloud/discoveryengine/v1/site_search_engine_client.cc @@ -365,6 +365,54 @@ SiteSearchEngineServiceClient::FetchDomainVerificationStatus( return connection_->FetchDomainVerificationStatus(std::move(request)); } +StreamRange +SiteSearchEngineServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +SiteSearchEngineServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +SiteSearchEngineServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +SiteSearchEngineServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status SiteSearchEngineServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status SiteSearchEngineServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1 } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/site_search_engine_client.h b/google/cloud/discoveryengine/v1/site_search_engine_client.h index ff45998b0522e..42d127b5476e6 100644 --- a/google/cloud/discoveryengine/v1/site_search_engine_client.h +++ b/google/cloud/discoveryengine/v1/site_search_engine_client.h @@ -1083,6 +1083,231 @@ class SiteSearchEngineServiceClient { request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/discoveryengine/v1/site_search_engine_connection.cc b/google/cloud/discoveryengine/v1/site_search_engine_connection.cc index b456b5ffc180d..c8f94f544e3e9 100644 --- a/google/cloud/discoveryengine/v1/site_search_engine_connection.cc +++ b/google/cloud/discoveryengine/v1/site_search_engine_connection.cc @@ -268,6 +268,25 @@ SiteSearchEngineServiceConnection::FetchDomainVerificationStatus( StreamRange>(); } +StreamRange +SiteSearchEngineServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +SiteSearchEngineServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status SiteSearchEngineServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSiteSearchEngineServiceConnection(Options options) { internal::CheckExpectedOptions ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/discoveryengine/v1/site_search_engine_connection_idempotency_policy.cc b/google/cloud/discoveryengine/v1/site_search_engine_connection_idempotency_policy.cc index b507efffbda75..6cb4b47fcfc47 100644 --- a/google/cloud/discoveryengine/v1/site_search_engine_connection_idempotency_policy.cc +++ b/google/cloud/discoveryengine/v1/site_search_engine_connection_idempotency_policy.cc @@ -107,6 +107,21 @@ Idempotency SiteSearchEngineServiceConnectionIdempotencyPolicy:: return Idempotency::kIdempotent; } +Idempotency SiteSearchEngineServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SiteSearchEngineServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency SiteSearchEngineServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultSiteSearchEngineServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/discoveryengine/v1/site_search_engine_connection_idempotency_policy.h b/google/cloud/discoveryengine/v1/site_search_engine_connection_idempotency_policy.h index 36128221e6273..2304ebf912a49 100644 --- a/google/cloud/discoveryengine/v1/site_search_engine_connection_idempotency_policy.h +++ b/google/cloud/discoveryengine/v1/site_search_engine_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 SiteSearchEngineServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency FetchDomainVerificationStatus( google::cloud::discoveryengine::v1::FetchDomainVerificationStatusRequest request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/discoveryengine/v1/user_event_client.cc b/google/cloud/discoveryengine/v1/user_event_client.cc index b50f5d45ff91b..6ce267f838f76 100644 --- a/google/cloud/discoveryengine/v1/user_event_client.cc +++ b/google/cloud/discoveryengine/v1/user_event_client.cc @@ -71,6 +71,52 @@ UserEventServiceClient::ImportUserEvents( return connection_->ImportUserEvents(operation); } +StreamRange +UserEventServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +UserEventServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr UserEventServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr UserEventServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status UserEventServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status UserEventServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace discoveryengine_v1 } // namespace cloud diff --git a/google/cloud/discoveryengine/v1/user_event_client.h b/google/cloud/discoveryengine/v1/user_event_client.h index 8b31c27aa86c3..f17679d0e6a4e 100644 --- a/google/cloud/discoveryengine/v1/user_event_client.h +++ b/google/cloud/discoveryengine/v1/user_event_client.h @@ -232,6 +232,231 @@ class UserEventServiceClient { ImportUserEvents(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/discoveryengine/v1/user_event_connection.cc b/google/cloud/discoveryengine/v1/user_event_connection.cc index 34283f93e277e..f2f91adc9436c 100644 --- a/google/cloud/discoveryengine/v1/user_event_connection.cc +++ b/google/cloud/discoveryengine/v1/user_event_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 @@ -72,6 +73,25 @@ UserEventServiceConnection::ImportUserEvents( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +UserEventServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +UserEventServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status UserEventServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeUserEventServiceConnection( Options options) { internal::CheckExpectedOptions #include @@ -208,6 +209,15 @@ class UserEventServiceConnection { virtual future< StatusOr> ImportUserEvents(google::longrunning::Operation const& operation); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/discoveryengine/v1/user_event_connection_idempotency_policy.cc b/google/cloud/discoveryengine/v1/user_event_connection_idempotency_policy.cc index 7b1beb9917c23..4a7aaf95707e2 100644 --- a/google/cloud/discoveryengine/v1/user_event_connection_idempotency_policy.cc +++ b/google/cloud/discoveryengine/v1/user_event_connection_idempotency_policy.cc @@ -49,6 +49,21 @@ Idempotency UserEventServiceConnectionIdempotencyPolicy::ImportUserEvents( return Idempotency::kNonIdempotent; } +Idempotency UserEventServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency UserEventServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency UserEventServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultUserEventServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/discoveryengine/v1/user_event_connection_idempotency_policy.h b/google/cloud/discoveryengine/v1/user_event_connection_idempotency_policy.h index dad1a65188288..a259d359b6815 100644 --- a/google/cloud/discoveryengine/v1/user_event_connection_idempotency_policy.h +++ b/google/cloud/discoveryengine/v1/user_event_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -47,6 +48,15 @@ class UserEventServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ImportUserEvents( google::cloud::discoveryengine::v1::ImportUserEventsRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr 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/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..2ae8585d72911 100644 --- a/google/cloud/documentai/v1/document_processor_client.cc +++ b/google/cloud/documentai/v1/document_processor_client.cc @@ -654,6 +654,68 @@ 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); +} + +StreamRange +DocumentProcessorServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +DocumentProcessorServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +DocumentProcessorServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +DocumentProcessorServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status DocumentProcessorServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status DocumentProcessorServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..a0ae9f6163a68 100644 --- a/google/cloud/documentai/v1/document_processor_client.h +++ b/google/cloud/documentai/v1/document_processor_client.h @@ -2027,6 +2027,301 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..5e7daae0230e6 100644 --- a/google/cloud/documentai/v1/document_processor_connection.cc +++ b/google/cloud/documentai/v1/document_processor_connection.cc @@ -378,6 +378,39 @@ 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"); +} + +StreamRange +DocumentProcessorServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +DocumentProcessorServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DocumentProcessorServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest 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..18cddb7c9cdf4 100644 --- a/google/cloud/documentai/v1/document_processor_connection.h +++ b/google/cloud/documentai/v1/document_processor_connection.h @@ -392,6 +392,21 @@ 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..d7391cafe6fe0 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,32 @@ 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; +} + +Idempotency DocumentProcessorServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DocumentProcessorServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +DocumentProcessorServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..f310f188407d4 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -108,6 +110,21 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..327811b08d911 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,50 @@ 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); +} + +StatusOr +DocumentProcessorServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +DocumentProcessorServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status DocumentProcessorServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..53a5552813526 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..1ff4704af6706 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,116 @@ 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__); +} + +StreamRange +DocumentProcessorServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DocumentProcessorServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DocumentProcessorServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..419bfcb8ad486 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..497019b4cbdb3 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,65 @@ 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_); +} + +StatusOr +DocumentProcessorServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DocumentProcessorServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DocumentProcessorServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..c8f99ebbb5bf6 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..656a05dc841f3 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,50 @@ 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); +} + +StatusOr +DocumentProcessorServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +DocumentProcessorServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status DocumentProcessorServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..3c593e945a903 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..04eb6da8661b8 100644 --- a/google/cloud/documentai/v1/internal/document_processor_stub.cc +++ b/google/cloud/documentai/v1/internal/document_processor_stub.cc @@ -524,6 +524,65 @@ 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; +} + +StatusOr +DefaultDocumentProcessorServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDocumentProcessorServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultDocumentProcessorServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..96ef22275b4c7 100644 --- a/google/cloud/documentai/v1/internal/document_processor_stub.h +++ b/google/cloud/documentai/v1/internal/document_processor_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -226,6 +227,27 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -246,9 +268,16 @@ class DefaultDocumentProcessorServiceStub std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ProcessDocument( grpc::ClientContext& context, Options const& options, @@ -442,6 +471,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -458,6 +507,10 @@ class DefaultDocumentProcessorServiceStub std::unique_ptr< google::cloud::documentai::v1::DocumentProcessorService::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..5fb039fb3600d 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -45,9 +47,14 @@ CreateDefaultDocumentProcessorServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::documentai::v1::DocumentProcessorService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..1717db82317ea 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,54 @@ 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)); +} + +StreamRange +DocumentProcessorServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "documentai_v1::DocumentProcessorServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DocumentProcessorServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "documentai_v1::DocumentProcessorServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status DocumentProcessorServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "documentai_v1::DocumentProcessorServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..272063c2d51e3 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..b70041e041f91 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,65 @@ 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)); +} + +StatusOr +DocumentProcessorServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.documentai.v1.DocumentProcessorService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +DocumentProcessorServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.documentai.v1.DocumentProcessorService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status DocumentProcessorServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.documentai.v1.DocumentProcessorService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..dde6da384237f 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..e0bb43ad06ba8 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,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..c91e48485e8de 100644 --- a/google/cloud/edgecontainer/v1/edge_container_client.cc +++ b/google/cloud/edgecontainer/v1/edge_container_client.cc @@ -614,6 +614,76 @@ 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); +} + +StreamRange EdgeContainerClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange EdgeContainerClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr EdgeContainerClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr EdgeContainerClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status EdgeContainerClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status EdgeContainerClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status EdgeContainerClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status EdgeContainerClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..8ee917d859b91 100644 --- a/google/cloud/edgecontainer/v1/edge_container_client.h +++ b/google/cloud/edgecontainer/v1/edge_container_client.h @@ -1845,6 +1845,356 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..78d575d138b89 100644 --- a/google/cloud/edgecontainer/v1/edge_container_connection.cc +++ b/google/cloud/edgecontainer/v1/edge_container_connection.cc @@ -315,6 +315,43 @@ 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"); +} + +StreamRange +EdgeContainerConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr EdgeContainerConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status EdgeContainerConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status EdgeContainerConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeEdgeContainerConnection( Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..6f8855f2f2f0d 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,36 @@ 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; +} + +Idempotency EdgeContainerConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency EdgeContainerConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency EdgeContainerConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency EdgeContainerConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..30a678ab26f40 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -100,6 +102,24 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..0bca6312d2faa 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,56 @@ 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); +} + +StatusOr +EdgeContainerAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr EdgeContainerAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status EdgeContainerAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status EdgeContainerAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..227eb71b20a9a 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..49735aca5c921 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,127 @@ 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__); +} + +StreamRange +EdgeContainerConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +EdgeContainerConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status EdgeContainerConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status EdgeContainerConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..90f49aa80a4fc 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..f94252a304109 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,74 @@ 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_); +} + +StatusOr +EdgeContainerLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr EdgeContainerLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status EdgeContainerLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status EdgeContainerLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..47fef0d683305 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..5bfa0a28422f3 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,56 @@ 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); +} + +StatusOr +EdgeContainerMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr EdgeContainerMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status EdgeContainerMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status EdgeContainerMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..af21b19661149 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..28e53e849d04a 100644 --- a/google/cloud/edgecontainer/v1/internal/edge_container_stub.cc +++ b/google/cloud/edgecontainer/v1/internal/edge_container_stub.cc @@ -450,6 +450,75 @@ 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; +} + +StatusOr +DefaultEdgeContainerStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultEdgeContainerStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultEdgeContainerStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultEdgeContainerStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..a880a60a84088 100644 --- a/google/cloud/edgecontainer/v1/internal/edge_container_stub.h +++ b/google/cloud/edgecontainer/v1/internal/edge_container_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -207,6 +208,31 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -226,9 +252,16 @@ class DefaultEdgeContainerStub : public EdgeContainerStub { std::unique_ptr< google::cloud::edgecontainer::v1::EdgeContainer::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListClusters( grpc::ClientContext& context, Options const& options, @@ -396,6 +429,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -412,6 +469,10 @@ class DefaultEdgeContainerStub : public EdgeContainerStub { std::unique_ptr< google::cloud::edgecontainer::v1::EdgeContainer::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..fefaee1dd0ac2 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,14 @@ std::shared_ptr CreateDefaultEdgeContainerStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::edgecontainer::v1::EdgeContainer::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..0ae731a45bae8 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,62 @@ 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)); +} + +StreamRange +EdgeContainerTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "edgecontainer_v1::EdgeContainerConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +EdgeContainerTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "edgecontainer_v1::EdgeContainerConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status EdgeContainerTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "edgecontainer_v1::EdgeContainerConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status EdgeContainerTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "edgecontainer_v1::EdgeContainerConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..8d930e3fe39a3 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..c6ea7b0d88da8 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,75 @@ 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)); +} + +StatusOr +EdgeContainerTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.edgecontainer.v1.EdgeContainer", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr EdgeContainerTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.edgecontainer.v1.EdgeContainer", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status EdgeContainerTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.edgecontainer.v1.EdgeContainer", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status EdgeContainerTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.edgecontainer.v1.EdgeContainer", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..aca685e333d6d 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..4c06962e77dce 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,29 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..b9f7f157bc9ad 100644 --- a/google/cloud/edgenetwork/v1/edge_network_client.cc +++ b/google/cloud/edgenetwork/v1/edge_network_client.cc @@ -730,6 +730,75 @@ 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); +} + +StreamRange EdgeNetworkClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange EdgeNetworkClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr EdgeNetworkClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr EdgeNetworkClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status EdgeNetworkClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status EdgeNetworkClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status EdgeNetworkClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status EdgeNetworkClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..544381e456d9c 100644 --- a/google/cloud/edgenetwork/v1/edge_network_client.h +++ b/google/cloud/edgenetwork/v1/edge_network_client.h @@ -2305,6 +2305,356 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..028912a1bce49 100644 --- a/google/cloud/edgenetwork/v1/edge_network_connection.cc +++ b/google/cloud/edgenetwork/v1/edge_network_connection.cc @@ -363,6 +363,42 @@ 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"); +} + +StreamRange +EdgeNetworkConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr EdgeNetworkConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status EdgeNetworkConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status EdgeNetworkConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeEdgeNetworkConnection( Options options) { internal::CheckExpectedOptions> DeleteRouter(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..8942d3dcfa633 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,36 @@ 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; +} + +Idempotency EdgeNetworkConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency EdgeNetworkConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency EdgeNetworkConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency EdgeNetworkConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..6b03944054395 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -118,6 +120,24 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..cca71df9bf2b5 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,56 @@ 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); +} + +StatusOr +EdgeNetworkAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr EdgeNetworkAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status EdgeNetworkAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status EdgeNetworkAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..6edf1f3b57c17 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..da75219e453c8 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,127 @@ 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__); +} + +StreamRange +EdgeNetworkConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +EdgeNetworkConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status EdgeNetworkConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status EdgeNetworkConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..98aa413619412 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..b455d1c5fb61e 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,74 @@ 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_); +} + +StatusOr +EdgeNetworkLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr EdgeNetworkLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status EdgeNetworkLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status EdgeNetworkLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..d6ba5b8f9eb63 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..cae664591acba 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,56 @@ 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); +} + +StatusOr +EdgeNetworkMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr EdgeNetworkMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status EdgeNetworkMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status EdgeNetworkMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..99b598b7df4ac 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..f3c05e9e96756 100644 --- a/google/cloud/edgenetwork/v1/internal/edge_network_stub.cc +++ b/google/cloud/edgenetwork/v1/internal/edge_network_stub.cc @@ -531,6 +531,74 @@ 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; +} + +StatusOr +DefaultEdgeNetworkStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultEdgeNetworkStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultEdgeNetworkStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultEdgeNetworkStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..6422fea49ffdd 100644 --- a/google/cloud/edgenetwork/v1/internal/edge_network_stub.h +++ b/google/cloud/edgenetwork/v1/internal/edge_network_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -224,6 +225,31 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -243,9 +269,16 @@ class DefaultEdgeNetworkStub : public EdgeNetworkStub { std::unique_ptr< google::cloud::edgenetwork::v1::EdgeNetwork::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr InitializeZone(grpc::ClientContext& context, Options const& options, @@ -449,6 +482,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -464,6 +521,10 @@ class DefaultEdgeNetworkStub : public EdgeNetworkStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..1a9a602dc9514 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,14 @@ std::shared_ptr CreateDefaultEdgeNetworkStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::edgenetwork::v1::EdgeNetwork::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..68bdb47f84190 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,62 @@ 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)); +} + +StreamRange +EdgeNetworkTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "edgenetwork_v1::EdgeNetworkConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +EdgeNetworkTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("edgenetwork_v1::EdgeNetworkConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status EdgeNetworkTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "edgenetwork_v1::EdgeNetworkConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status EdgeNetworkTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "edgenetwork_v1::EdgeNetworkConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..ba6913930e6b8 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..17d120363ac11 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,74 @@ 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)); +} + +StatusOr +EdgeNetworkTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.edgenetwork.v1.EdgeNetwork", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr EdgeNetworkTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.edgenetwork.v1.EdgeNetwork", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status EdgeNetworkTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.edgenetwork.v1.EdgeNetwork", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status EdgeNetworkTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.edgenetwork.v1.EdgeNetwork", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..3cfe7c3c3e3a5 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..13e5266fface6 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,29 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..4d7d9e76d3922 100644 --- a/google/cloud/eventarc/v1/eventarc_client.cc +++ b/google/cloud/eventarc/v1/eventarc_client.cc @@ -550,6 +550,92 @@ 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); +} + +StreamRange EventarcClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange EventarcClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr EventarcClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr EventarcClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status EventarcClient::DeleteOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status EventarcClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status EventarcClient::CancelOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status EventarcClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..25bfefca9727a 100644 --- a/google/cloud/eventarc/v1/eventarc_client.h +++ b/google/cloud/eventarc/v1/eventarc_client.h @@ -1669,6 +1669,458 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..022f78f7ce890 100644 --- a/google/cloud/eventarc/v1/eventarc_connection.cc +++ b/google/cloud/eventarc/v1/eventarc_connection.cc @@ -277,6 +277,57 @@ 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"); +} + +StreamRange EventarcConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr EventarcConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status EventarcConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status EventarcConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeEventarcConnection(Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..10e3edf7e0f4e 100644 --- a/google/cloud/eventarc/v1/eventarc_connection_idempotency_policy.cc +++ b/google/cloud/eventarc/v1/eventarc_connection_idempotency_policy.cc @@ -124,6 +124,52 @@ 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; +} + +Idempotency EventarcConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency EventarcConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency EventarcConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency EventarcConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..1b6d10b68214d 100644 --- a/google/cloud/eventarc/v1/eventarc_connection_idempotency_policy.h +++ b/google/cloud/eventarc/v1/eventarc_connection_idempotency_policy.h @@ -22,6 +22,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -93,6 +96,33 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..9aa8d7f20512e 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_auth_decorator.cc +++ b/google/cloud/eventarc/v1/internal/eventarc_auth_decorator.cc @@ -347,6 +347,81 @@ 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); +} + +StatusOr +EventarcAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr EventarcAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status EventarcAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status EventarcAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..5c8e676dd27bb 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_auth_decorator.h +++ b/google/cloud/eventarc/v1/internal/eventarc_auth_decorator.h @@ -183,6 +183,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..a82ed48fbef22 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_connection_impl.cc +++ b/google/cloud/eventarc/v1/internal/eventarc_connection_impl.cc @@ -1012,6 +1012,165 @@ 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__); +} + +StreamRange +EventarcConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr EventarcConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status EventarcConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status EventarcConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..776528aaad2f0 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_connection_impl.h +++ b/google/cloud/eventarc/v1/internal/eventarc_connection_impl.h @@ -188,6 +188,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..63c698680d767 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_logging_decorator.cc +++ b/google/cloud/eventarc/v1/internal/eventarc_logging_decorator.cc @@ -400,6 +400,108 @@ 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_); +} + +StatusOr +EventarcLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr EventarcLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status EventarcLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status EventarcLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..5b9a985c41196 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_logging_decorator.h +++ b/google/cloud/eventarc/v1/internal/eventarc_logging_decorator.h @@ -183,6 +183,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..a76f52bdc65f8 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_metadata_decorator.cc +++ b/google/cloud/eventarc/v1/internal/eventarc_metadata_decorator.cc @@ -304,6 +304,84 @@ 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); +} + +StatusOr +EventarcMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr EventarcMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status EventarcMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status EventarcMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..5d46f63366c32 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_metadata_decorator.h +++ b/google/cloud/eventarc/v1/internal/eventarc_metadata_decorator.h @@ -183,6 +183,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..819266bd03342 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_stub.cc +++ b/google/cloud/eventarc/v1/internal/eventarc_stub.cc @@ -395,6 +395,109 @@ 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; +} + +StatusOr +DefaultEventarcStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultEventarcStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultEventarcStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultEventarcStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..e089f0b7b7e3c 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_stub.h +++ b/google/cloud/eventarc/v1/internal/eventarc_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,44 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -193,9 +233,18 @@ class DefaultEventarcStub : public EventarcStub { DefaultEventarcStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +390,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -356,6 +441,11 @@ class DefaultEventarcStub : public EventarcStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..28106cd5df679 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_stub_factory.cc +++ b/google/cloud/eventarc/v1/internal/eventarc_stub_factory.cc @@ -29,6 +29,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,8 +47,14 @@ std::shared_ptr CreateDefaultEventarcStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::eventarc::v1::Eventarc::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..374fdafbd0b48 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_tracing_connection.cc +++ b/google/cloud/eventarc/v1/internal/eventarc_tracing_connection.cc @@ -365,6 +365,87 @@ 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)); +} + +StreamRange +EventarcTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("eventarc_v1::EventarcConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +EventarcTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("eventarc_v1::EventarcConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status EventarcTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = + internal::MakeSpan("eventarc_v1::EventarcConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status EventarcTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("eventarc_v1::EventarcConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..eb2d271006ee3 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_tracing_connection.h +++ b/google/cloud/eventarc/v1/internal/eventarc_tracing_connection.h @@ -176,6 +176,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..b06ee5418ef7e 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_tracing_stub.cc +++ b/google/cloud/eventarc/v1/internal/eventarc_tracing_stub.cc @@ -363,6 +363,108 @@ 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)); +} + +StatusOr +EventarcTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.eventarc.v1.Eventarc", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr EventarcTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.eventarc.v1.Eventarc", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status EventarcTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.eventarc.v1.Eventarc", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status EventarcTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.eventarc.v1.Eventarc", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..a9787d23dbc5f 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_tracing_stub.h +++ b/google/cloud/eventarc/v1/internal/eventarc_tracing_stub.h @@ -182,6 +182,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..a0d3fcbe50399 100644 --- a/google/cloud/eventarc/v1/mocks/mock_eventarc_connection.h +++ b/google/cloud/eventarc/v1/mocks/mock_eventarc_connection.h @@ -407,6 +407,42 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..c3890a64e6bdb 100644 --- a/google/cloud/filestore/v1/cloud_filestore_manager_client.cc +++ b/google/cloud/filestore/v1/cloud_filestore_manager_client.cc @@ -592,6 +592,82 @@ 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); +} + +StreamRange +CloudFilestoreManagerClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +CloudFilestoreManagerClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +CloudFilestoreManagerClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +CloudFilestoreManagerClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status CloudFilestoreManagerClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status CloudFilestoreManagerClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status CloudFilestoreManagerClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status CloudFilestoreManagerClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..fe41b5f5a1b05 100644 --- a/google/cloud/filestore/v1/cloud_filestore_manager_client.h +++ b/google/cloud/filestore/v1/cloud_filestore_manager_client.h @@ -1727,6 +1727,356 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..d00d9e9d61995 100644 --- a/google/cloud/filestore/v1/cloud_filestore_manager_connection.cc +++ b/google/cloud/filestore/v1/cloud_filestore_manager_connection.cc @@ -333,6 +333,44 @@ 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"); +} + +StreamRange +CloudFilestoreManagerConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +CloudFilestoreManagerConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status CloudFilestoreManagerConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status CloudFilestoreManagerConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeCloudFilestoreManagerConnection(Options options) { internal::CheckExpectedOptions> UpdateBackup( google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..5cd9cd2d590ff 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,36 @@ 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; +} + +Idempotency CloudFilestoreManagerConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency CloudFilestoreManagerConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency CloudFilestoreManagerConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency CloudFilestoreManagerConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..cb0789ca2f5ab 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -87,6 +89,24 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..2435b5e11dc4e 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,58 @@ 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); +} + +StatusOr +CloudFilestoreManagerAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +CloudFilestoreManagerAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status CloudFilestoreManagerAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status CloudFilestoreManagerAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..e4252e316ad2f 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..1758bf66f662e 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,127 @@ 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__); +} + +StreamRange +CloudFilestoreManagerConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +CloudFilestoreManagerConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status CloudFilestoreManagerConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status CloudFilestoreManagerConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..3e3c2c4331aaa 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..52701b6e2f375 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,76 @@ 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_); +} + +StatusOr +CloudFilestoreManagerLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +CloudFilestoreManagerLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status CloudFilestoreManagerLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status CloudFilestoreManagerLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..89968958605c7 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..f3047558078e0 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,58 @@ 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); +} + +StatusOr +CloudFilestoreManagerMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +CloudFilestoreManagerMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status CloudFilestoreManagerMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status CloudFilestoreManagerMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..0cb608c6614ee 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..ba8835ac6757f 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,76 @@ 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; +} + +StatusOr +DefaultCloudFilestoreManagerStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultCloudFilestoreManagerStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultCloudFilestoreManagerStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultCloudFilestoreManagerStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..70e73a75391cc 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,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -175,6 +176,31 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -194,9 +220,16 @@ class DefaultCloudFilestoreManagerStub : public CloudFilestoreManagerStub { std::unique_ptr< google::cloud::filestore::v1::CloudFilestoreManager::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListInstances( grpc::ClientContext& context, Options const& options, @@ -356,6 +389,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -372,6 +429,10 @@ class DefaultCloudFilestoreManagerStub : public CloudFilestoreManagerStub { std::unique_ptr< google::cloud::filestore::v1::CloudFilestoreManager::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..7922b84d017ca 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -45,9 +47,14 @@ CreateDefaultCloudFilestoreManagerStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::filestore::v1::CloudFilestoreManager::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..f5c4af77564b9 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,62 @@ 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)); +} + +StreamRange +CloudFilestoreManagerTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "filestore_v1::CloudFilestoreManagerConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +CloudFilestoreManagerTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "filestore_v1::CloudFilestoreManagerConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status CloudFilestoreManagerTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "filestore_v1::CloudFilestoreManagerConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status CloudFilestoreManagerTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "filestore_v1::CloudFilestoreManagerConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..a473753928902 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..46b474e8ecd97 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,76 @@ 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)); +} + +StatusOr +CloudFilestoreManagerTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.filestore.v1.CloudFilestoreManager", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +CloudFilestoreManagerTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.filestore.v1.CloudFilestoreManager", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status CloudFilestoreManagerTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.filestore.v1.CloudFilestoreManager", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status CloudFilestoreManagerTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.filestore.v1.CloudFilestoreManager", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..42b11b6c15228 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..e59783b369e4c 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,29 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..51e6de0e87db8 100644 --- a/google/cloud/functions/v1/cloud_functions_client.cc +++ b/google/cloud/functions/v1/cloud_functions_client.cc @@ -241,6 +241,47 @@ 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)); +} + +StreamRange +CloudFunctionsServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +CloudFunctionsServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +CloudFunctionsServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +CloudFunctionsServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(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 5b60caf5b9c1d..b6672e7990769 100644 --- a/google/cloud/functions/v1/cloud_functions_client.h +++ b/google/cloud/functions/v1/cloud_functions_client.h @@ -793,6 +793,197 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& 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..ffbd25d9ea416 100644 --- a/google/cloud/functions/v1/cloud_functions_connection.cc +++ b/google/cloud/functions/v1/cloud_functions_connection.cc @@ -155,6 +155,28 @@ 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>(); +} + +StreamRange +CloudFunctionsServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +CloudFunctionsServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeCloudFunctionsServiceConnection(Options options) { internal::CheckExpectedOptions TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& 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..fd2b9e16baba2 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,21 @@ CloudFunctionsServiceConnectionIdempotencyPolicy::TestIamPermissions( return Idempotency::kIdempotent; } +Idempotency CloudFunctionsServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency CloudFunctionsServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency CloudFunctionsServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + 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..dbf704d99ea47 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -69,6 +71,15 @@ class CloudFunctionsServiceConnectionIdempotencyPolicy { 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 ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& 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..8f9395bc74818 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,33 @@ 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); +} + +StatusOr +CloudFunctionsServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +CloudFunctionsServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(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..46314a2382d5c 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,18 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..58e14e6bee0a0 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,87 @@ 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; + }); +} + +StreamRange +CloudFunctionsServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +CloudFunctionsServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + 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..92772b028fd0b 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,15 @@ class CloudFunctionsServiceConnectionImpl StatusOr TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& 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..de8615cf4ff1d 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,42 @@ 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_); +} + +StatusOr +CloudFunctionsServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +CloudFunctionsServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(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..aecc062de652d 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,18 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..7d817465da42d 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,32 @@ 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); +} + +StatusOr +CloudFunctionsServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, absl::StrCat()); + return child_->ListOperations(context, options, request); +} + +StatusOr +CloudFunctionsServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(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..57b57419a0eeb 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,18 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..a949543fb7c60 100644 --- a/google/cloud/functions/v1/internal/cloud_functions_stub.cc +++ b/google/cloud/functions/v1/internal/cloud_functions_stub.cc @@ -217,6 +217,42 @@ 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; +} + +StatusOr +DefaultCloudFunctionsServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultCloudFunctionsServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&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..65fdaeb2ab218 100644 --- a/google/cloud/functions/v1/internal/cloud_functions_stub.h +++ b/google/cloud/functions/v1/internal/cloud_functions_stub.h @@ -26,6 +26,7 @@ #include "google/cloud/version.h" #include #include +#include #include #include #include @@ -108,6 +109,19 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -127,9 +141,16 @@ class DefaultCloudFunctionsServiceStub : public CloudFunctionsServiceStub { std::unique_ptr< google::cloud::functions::v1::CloudFunctionsService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListFunctions( grpc::ClientContext& context, Options const& options, @@ -205,6 +226,18 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -221,6 +254,10 @@ class DefaultCloudFunctionsServiceStub : public CloudFunctionsServiceStub { std::unique_ptr< google::cloud::functions::v1::CloudFunctionsService::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..77c8b34591eb7 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -45,9 +47,14 @@ CreateDefaultCloudFunctionsServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::functions::v1::CloudFunctionsService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..89898fae8b7c1 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,37 @@ 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)); +} + +StreamRange +CloudFunctionsServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "functions_v1::CloudFunctionsServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +CloudFunctionsServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "functions_v1::CloudFunctionsServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #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..800874f7b74d1 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,15 @@ class CloudFunctionsServiceTracingConnection StatusOr TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& 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..ab6dd00a64f65 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,42 @@ 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)); +} + +StatusOr +CloudFunctionsServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.functions.v1.CloudFunctionsService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +CloudFunctionsServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.functions.v1.CloudFunctionsService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(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..561bc57abe08a 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,18 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..41479b065b9c5 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,17 @@ class MockCloudFunctionsServiceConnection TestIamPermissions, (google::iam::v1::TestIamPermissionsRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& 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..e7c017ceef4db 100644 --- a/google/cloud/functions/v2/function_client.cc +++ b/google/cloud/functions/v2/function_client.cc @@ -226,6 +226,63 @@ 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); +} + +StreamRange +FunctionServiceClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +FunctionServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr FunctionServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr FunctionServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(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 ed9445eea650a..8ba0b1f4755a1 100644 --- a/google/cloud/functions/v2/function_client.h +++ b/google/cloud/functions/v2/function_client.h @@ -736,6 +736,299 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest 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..03fff302c9e9b 100644 --- a/google/cloud/functions/v2/function_connection.cc +++ b/google/cloud/functions/v2/function_connection.cc @@ -139,6 +139,44 @@ 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"); +} + +StreamRange +FunctionServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +FunctionServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeFunctionServiceConnection( Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest 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..54ff6eb9a4620 100644 --- a/google/cloud/functions/v2/function_connection_idempotency_policy.cc +++ b/google/cloud/functions/v2/function_connection_idempotency_policy.cc @@ -74,6 +74,37 @@ 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; +} + +Idempotency FunctionServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency FunctionServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest 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..c4de7695a2295 100644 --- a/google/cloud/functions/v2/function_connection_idempotency_policy.h +++ b/google/cloud/functions/v2/function_connection_idempotency_policy.h @@ -22,6 +22,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -60,6 +63,24 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest 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..24a6647e9085e 100644 --- a/google/cloud/functions/v2/internal/function_auth_decorator.cc +++ b/google/cloud/functions/v2/internal/function_auth_decorator.cc @@ -160,6 +160,57 @@ 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); +} + +StatusOr +FunctionServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr FunctionServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(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..618439e61377e 100644 --- a/google/cloud/functions/v2/internal/function_auth_decorator.h +++ b/google/cloud/functions/v2/internal/function_auth_decorator.h @@ -101,6 +101,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..9389aeb3d9dff 100644 --- a/google/cloud/functions/v2/internal/function_connection_impl.cc +++ b/google/cloud/functions/v2/internal/function_connection_impl.cc @@ -432,6 +432,127 @@ 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__); +} + +StreamRange +FunctionServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +FunctionServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(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..8cac7d09ef637 100644 --- a/google/cloud/functions/v2/internal/function_connection_impl.h +++ b/google/cloud/functions/v2/internal/function_connection_impl.h @@ -108,6 +108,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest 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..0cb12ff8e9a3b 100644 --- a/google/cloud/functions/v2/internal/function_logging_decorator.cc +++ b/google/cloud/functions/v2/internal/function_logging_decorator.cc @@ -191,6 +191,75 @@ 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_); +} + +StatusOr +FunctionServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr FunctionServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(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..47ab7ad1eb567 100644 --- a/google/cloud/functions/v2/internal/function_logging_decorator.h +++ b/google/cloud/functions/v2/internal/function_logging_decorator.h @@ -101,6 +101,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..9caa21fe31ef9 100644 --- a/google/cloud/functions/v2/internal/function_metadata_decorator.cc +++ b/google/cloud/functions/v2/internal/function_metadata_decorator.cc @@ -154,6 +154,60 @@ 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); +} + +StatusOr +FunctionServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr FunctionServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(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..fa804a69afc4e 100644 --- a/google/cloud/functions/v2/internal/function_metadata_decorator.h +++ b/google/cloud/functions/v2/internal/function_metadata_decorator.h @@ -102,6 +102,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..85e7e6b780e3f 100644 --- a/google/cloud/functions/v2/internal/function_stub.cc +++ b/google/cloud/functions/v2/internal/function_stub.cc @@ -181,6 +181,77 @@ 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; +} + +StatusOr +DefaultFunctionServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultFunctionServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&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..02b66418dbf0f 100644 --- a/google/cloud/functions/v2/internal/function_stub.h +++ b/google/cloud/functions/v2/internal/function_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,32 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -113,9 +141,18 @@ class DefaultFunctionServiceStub : public FunctionServiceStub { std::unique_ptr< google::cloud::functions::v2::FunctionService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +216,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -194,6 +255,11 @@ class DefaultFunctionServiceStub : public FunctionServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..2e6ea41f45df2 100644 --- a/google/cloud/functions/v2/internal/function_stub_factory.cc +++ b/google/cloud/functions/v2/internal/function_stub_factory.cc @@ -29,6 +29,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultFunctionServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::functions::v2::FunctionService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..903893bf801d8 100644 --- a/google/cloud/functions/v2/internal/function_tracing_connection.cc +++ b/google/cloud/functions/v2/internal/function_tracing_connection.cc @@ -167,6 +167,64 @@ 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)); +} + +StreamRange +FunctionServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "functions_v2::FunctionServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +FunctionServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "functions_v2::FunctionServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(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..eff24648fa6cd 100644 --- a/google/cloud/functions/v2/internal/function_tracing_connection.h +++ b/google/cloud/functions/v2/internal/function_tracing_connection.h @@ -96,6 +96,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest 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..549b3e3113481 100644 --- a/google/cloud/functions/v2/internal/function_tracing_stub.cc +++ b/google/cloud/functions/v2/internal/function_tracing_stub.cc @@ -173,6 +173,76 @@ 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)); +} + +StatusOr +FunctionServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.functions.v2.FunctionService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +FunctionServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.functions.v2.FunctionService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(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..aec1e7f0f8ed2 100644 --- a/google/cloud/functions/v2/internal/function_tracing_stub.h +++ b/google/cloud/functions/v2/internal/function_tracing_stub.h @@ -101,6 +101,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..dfa39f5ccf0d1 100644 --- a/google/cloud/functions/v2/mocks/mock_function_connection.h +++ b/google/cloud/functions/v2/mocks/mock_function_connection.h @@ -188,6 +188,30 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest 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..b15b6177fe68b 100644 --- a/google/cloud/gkebackup/v1/backup_for_gke_client.cc +++ b/google/cloud/gkebackup/v1/backup_for_gke_client.cc @@ -763,6 +763,95 @@ 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); +} + +StreamRange BackupForGKEClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange BackupForGKEClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr BackupForGKEClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr BackupForGKEClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status BackupForGKEClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status BackupForGKEClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status BackupForGKEClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status BackupForGKEClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..30bc4271375ab 100644 --- a/google/cloud/gkebackup/v1/backup_for_gke_client.h +++ b/google/cloud/gkebackup/v1/backup_for_gke_client.h @@ -2398,6 +2398,458 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..9adae37db6779 100644 --- a/google/cloud/gkebackup/v1/backup_for_gke_connection.cc +++ b/google/cloud/gkebackup/v1/backup_for_gke_connection.cc @@ -392,6 +392,58 @@ 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"); +} + +StreamRange +BackupForGKEConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr BackupForGKEConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status BackupForGKEConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status BackupForGKEConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeBackupForGKEConnection( Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..cd27880c9e58f 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,52 @@ 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; +} + +Idempotency BackupForGKEConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency BackupForGKEConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency BackupForGKEConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency BackupForGKEConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..107a68257f962 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,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -112,6 +115,33 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..e32f66ed0e5e5 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,81 @@ 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); +} + +StatusOr +BackupForGKEAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr BackupForGKEAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status BackupForGKEAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status BackupForGKEAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..cb782879e3cc6 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..8aa0ef3dc1f32 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,167 @@ 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__); +} + +StreamRange +BackupForGKEConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +BackupForGKEConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status BackupForGKEConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status BackupForGKEConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..f8c4706be41eb 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..6fbca73e87967 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,108 @@ 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_); +} + +StatusOr +BackupForGKELogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr BackupForGKELogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status BackupForGKELogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status BackupForGKELogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..051ca1f0c15ac 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..8c7bb3ee3431b 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,84 @@ 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); +} + +StatusOr +BackupForGKEMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr BackupForGKEMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status BackupForGKEMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status BackupForGKEMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..9f7510239913f 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..9d2a8ca0a663b 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,110 @@ 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; +} + +StatusOr +DefaultBackupForGKEStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultBackupForGKEStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultBackupForGKEStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultBackupForGKEStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..314809b3a4b5b 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,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -234,6 +236,44 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -252,9 +292,18 @@ class DefaultBackupForGKEStub : public BackupForGKEStub { DefaultBackupForGKEStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +514,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -480,6 +565,11 @@ class DefaultBackupForGKEStub : public BackupForGKEStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..39bef09ce3bc0 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,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultBackupForGKEStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::gkebackup::v1::BackupForGKE::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..a178443f4d7d2 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,87 @@ 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)); +} + +StreamRange +BackupForGKETracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "gkebackup_v1::BackupForGKEConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +BackupForGKETracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("gkebackup_v1::BackupForGKEConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status BackupForGKETracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "gkebackup_v1::BackupForGKEConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status BackupForGKETracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "gkebackup_v1::BackupForGKEConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..3946c5423fd12 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..61b23f213bf02 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,109 @@ 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)); +} + +StatusOr +BackupForGKETracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.gkebackup.v1.BackupForGKE", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr BackupForGKETracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.gkebackup.v1.BackupForGKE", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status BackupForGKETracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.gkebackup.v1.BackupForGKE", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status BackupForGKETracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.gkebackup.v1.BackupForGKE", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..4512224aacba3 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..f79e3a1dbfea9 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,42 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/gkemulticloud/v1/attached_clusters_client.cc b/google/cloud/gkemulticloud/v1/attached_clusters_client.cc index 79cc4a9a82744..dd666308e145c 100644 --- a/google/cloud/gkemulticloud/v1/attached_clusters_client.cc +++ b/google/cloud/gkemulticloud/v1/attached_clusters_client.cc @@ -311,6 +311,66 @@ AttachedClustersClient::GenerateAttachedClusterAgentToken( return connection_->GenerateAttachedClusterAgentToken(request); } +StreamRange +AttachedClustersClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +AttachedClustersClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr AttachedClustersClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr AttachedClustersClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status AttachedClustersClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status AttachedClustersClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status AttachedClustersClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status AttachedClustersClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace gkemulticloud_v1 } // namespace cloud diff --git a/google/cloud/gkemulticloud/v1/attached_clusters_client.h b/google/cloud/gkemulticloud/v1/attached_clusters_client.h index b6c9ecf766cec..a8851ebf22a1c 100644 --- a/google/cloud/gkemulticloud/v1/attached_clusters_client.h +++ b/google/cloud/gkemulticloud/v1/attached_clusters_client.h @@ -1004,6 +1004,286 @@ class AttachedClustersClient { GenerateAttachedClusterAgentTokenRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/gkemulticloud/v1/attached_clusters_connection.cc b/google/cloud/gkemulticloud/v1/attached_clusters_connection.cc index c234141f16ed0..df36f8b0706f4 100644 --- a/google/cloud/gkemulticloud/v1/attached_clusters_connection.cc +++ b/google/cloud/gkemulticloud/v1/attached_clusters_connection.cc @@ -170,6 +170,30 @@ AttachedClustersConnection::GenerateAttachedClusterAgentToken( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +AttachedClustersConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +AttachedClustersConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AttachedClustersConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AttachedClustersConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeAttachedClustersConnection( std::string const& location, Options options) { internal::CheckExpectedOptions ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/gkemulticloud/v1/attached_clusters_connection_idempotency_policy.cc b/google/cloud/gkemulticloud/v1/attached_clusters_connection_idempotency_policy.cc index 31f784866bcb5..e1c42429671ed 100644 --- a/google/cloud/gkemulticloud/v1/attached_clusters_connection_idempotency_policy.cc +++ b/google/cloud/gkemulticloud/v1/attached_clusters_connection_idempotency_policy.cc @@ -84,6 +84,26 @@ AttachedClustersConnectionIdempotencyPolicy::GenerateAttachedClusterAgentToken( return Idempotency::kNonIdempotent; } +Idempotency AttachedClustersConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AttachedClustersConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AttachedClustersConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AttachedClustersConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultAttachedClustersConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/gkemulticloud/v1/attached_clusters_connection_idempotency_policy.h b/google/cloud/gkemulticloud/v1/attached_clusters_connection_idempotency_policy.h index 669a375251b10..560d371e2aeef 100644 --- a/google/cloud/gkemulticloud/v1/attached_clusters_connection_idempotency_policy.h +++ b/google/cloud/gkemulticloud/v1/attached_clusters_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,18 @@ class AttachedClustersConnectionIdempotencyPolicy { virtual google::cloud::Idempotency GenerateAttachedClusterAgentToken( google::cloud::gkemulticloud::v1:: GenerateAttachedClusterAgentTokenRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/gkemulticloud/v1/aws_clusters_client.cc b/google/cloud/gkemulticloud/v1/aws_clusters_client.cc index f1bc8472da696..8507c1f105005 100644 --- a/google/cloud/gkemulticloud/v1/aws_clusters_client.cc +++ b/google/cloud/gkemulticloud/v1/aws_clusters_client.cc @@ -454,6 +454,63 @@ AwsClustersClient::GetAwsServerConfig( return connection_->GetAwsServerConfig(request); } +StreamRange AwsClustersClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange AwsClustersClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr AwsClustersClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr AwsClustersClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status AwsClustersClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status AwsClustersClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status AwsClustersClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status AwsClustersClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace gkemulticloud_v1 } // namespace cloud diff --git a/google/cloud/gkemulticloud/v1/aws_clusters_client.h b/google/cloud/gkemulticloud/v1/aws_clusters_client.h index 6d0a9c5089985..731418bc259bd 100644 --- a/google/cloud/gkemulticloud/v1/aws_clusters_client.h +++ b/google/cloud/gkemulticloud/v1/aws_clusters_client.h @@ -1554,6 +1554,286 @@ class AwsClustersClient { request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/gkemulticloud/v1/aws_clusters_connection.cc b/google/cloud/gkemulticloud/v1/aws_clusters_connection.cc index dcd37e7a50f79..9ef97f4ae17e2 100644 --- a/google/cloud/gkemulticloud/v1/aws_clusters_connection.cc +++ b/google/cloud/gkemulticloud/v1/aws_clusters_connection.cc @@ -262,6 +262,29 @@ AwsClustersConnection::GetAwsServerConfig( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +AwsClustersConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr AwsClustersConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AwsClustersConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AwsClustersConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeAwsClustersConnection( std::string const& location, Options options) { internal::CheckExpectedOptions ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/gkemulticloud/v1/aws_clusters_connection_idempotency_policy.cc b/google/cloud/gkemulticloud/v1/aws_clusters_connection_idempotency_policy.cc index 71ccf5a814dc9..278c1eba0b3c1 100644 --- a/google/cloud/gkemulticloud/v1/aws_clusters_connection_idempotency_policy.cc +++ b/google/cloud/gkemulticloud/v1/aws_clusters_connection_idempotency_policy.cc @@ -116,6 +116,26 @@ Idempotency AwsClustersConnectionIdempotencyPolicy::GetAwsServerConfig( return Idempotency::kIdempotent; } +Idempotency AwsClustersConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AwsClustersConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AwsClustersConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AwsClustersConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultAwsClustersConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/gkemulticloud/v1/aws_clusters_connection_idempotency_policy.h b/google/cloud/gkemulticloud/v1/aws_clusters_connection_idempotency_policy.h index c4f15b520730c..078a5c4c5b1f0 100644 --- a/google/cloud/gkemulticloud/v1/aws_clusters_connection_idempotency_policy.h +++ b/google/cloud/gkemulticloud/v1/aws_clusters_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -92,6 +93,18 @@ class AwsClustersConnectionIdempotencyPolicy { virtual google::cloud::Idempotency GetAwsServerConfig( google::cloud::gkemulticloud::v1::GetAwsServerConfigRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/gkemulticloud/v1/azure_clusters_client.cc b/google/cloud/gkemulticloud/v1/azure_clusters_client.cc index 2a3e4e62a2c73..70899e352fabd 100644 --- a/google/cloud/gkemulticloud/v1/azure_clusters_client.cc +++ b/google/cloud/gkemulticloud/v1/azure_clusters_client.cc @@ -566,6 +566,63 @@ AzureClustersClient::GetAzureServerConfig( return connection_->GetAzureServerConfig(request); } +StreamRange AzureClustersClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange AzureClustersClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr AzureClustersClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr AzureClustersClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status AzureClustersClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status AzureClustersClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status AzureClustersClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status AzureClustersClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace gkemulticloud_v1 } // namespace cloud diff --git a/google/cloud/gkemulticloud/v1/azure_clusters_client.h b/google/cloud/gkemulticloud/v1/azure_clusters_client.h index cfbbd74827c6f..0c2bd44b43bac 100644 --- a/google/cloud/gkemulticloud/v1/azure_clusters_client.h +++ b/google/cloud/gkemulticloud/v1/azure_clusters_client.h @@ -1968,6 +1968,286 @@ class AzureClustersClient { request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/gkemulticloud/v1/azure_clusters_connection.cc b/google/cloud/gkemulticloud/v1/azure_clusters_connection.cc index dfca692bfb0cb..8b349e728439e 100644 --- a/google/cloud/gkemulticloud/v1/azure_clusters_connection.cc +++ b/google/cloud/gkemulticloud/v1/azure_clusters_connection.cc @@ -304,6 +304,29 @@ AzureClustersConnection::GetAzureServerConfig( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +AzureClustersConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr AzureClustersConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AzureClustersConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AzureClustersConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeAzureClustersConnection( std::string const& location, Options options) { internal::CheckExpectedOptions ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/gkemulticloud/v1/azure_clusters_connection_idempotency_policy.cc b/google/cloud/gkemulticloud/v1/azure_clusters_connection_idempotency_policy.cc index 6f992fa24ccdb..c35a384e33b34 100644 --- a/google/cloud/gkemulticloud/v1/azure_clusters_connection_idempotency_policy.cc +++ b/google/cloud/gkemulticloud/v1/azure_clusters_connection_idempotency_policy.cc @@ -131,6 +131,26 @@ Idempotency AzureClustersConnectionIdempotencyPolicy::GetAzureServerConfig( return Idempotency::kIdempotent; } +Idempotency AzureClustersConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AzureClustersConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AzureClustersConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AzureClustersConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultAzureClustersConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/gkemulticloud/v1/azure_clusters_connection_idempotency_policy.h b/google/cloud/gkemulticloud/v1/azure_clusters_connection_idempotency_policy.h index 5af4c2a11c418..1e2fd0d1371cf 100644 --- a/google/cloud/gkemulticloud/v1/azure_clusters_connection_idempotency_policy.h +++ b/google/cloud/gkemulticloud/v1/azure_clusters_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,18 @@ class AzureClustersConnectionIdempotencyPolicy { virtual google::cloud::Idempotency GetAzureServerConfig( google::cloud::gkemulticloud::v1::GetAzureServerConfigRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/gkemulticloud/v1/internal/attached_clusters_auth_decorator.cc b/google/cloud/gkemulticloud/v1/internal/attached_clusters_auth_decorator.cc index 4e21a66c7d8ed..357e70bbeb82f 100644 --- a/google/cloud/gkemulticloud/v1/internal/attached_clusters_auth_decorator.cc +++ b/google/cloud/gkemulticloud/v1/internal/attached_clusters_auth_decorator.cc @@ -208,6 +208,39 @@ AttachedClustersAuth::GenerateAttachedClusterAgentToken( return child_->GenerateAttachedClusterAgentToken(context, options, request); } +StatusOr +AttachedClustersAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr AttachedClustersAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status AttachedClustersAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status AttachedClustersAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + future> AttachedClustersAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/gkemulticloud/v1/internal/attached_clusters_auth_decorator.h b/google/cloud/gkemulticloud/v1/internal/attached_clusters_auth_decorator.h index aaec0c8a2f599..5c4a108b325ee 100644 --- a/google/cloud/gkemulticloud/v1/internal/attached_clusters_auth_decorator.h +++ b/google/cloud/gkemulticloud/v1/internal/attached_clusters_auth_decorator.h @@ -120,6 +120,22 @@ class AttachedClustersAuth : public AttachedClustersStub { google::cloud::gkemulticloud::v1:: GenerateAttachedClusterAgentTokenRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/gkemulticloud/v1/internal/attached_clusters_connection_impl.cc b/google/cloud/gkemulticloud/v1/internal/attached_clusters_connection_impl.cc index c959b46596074..edd930e26c314 100644 --- a/google/cloud/gkemulticloud/v1/internal/attached_clusters_connection_impl.cc +++ b/google/cloud/gkemulticloud/v1/internal/attached_clusters_connection_impl.cc @@ -561,6 +561,79 @@ AttachedClustersConnectionImpl::GenerateAttachedClusterAgentToken( *current, request, __func__); } +StreamRange +AttachedClustersConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +AttachedClustersConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status AttachedClustersConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status AttachedClustersConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace gkemulticloud_v1_internal } // namespace cloud diff --git a/google/cloud/gkemulticloud/v1/internal/attached_clusters_connection_impl.h b/google/cloud/gkemulticloud/v1/internal/attached_clusters_connection_impl.h index 49afee7682f52..48e5b4e0400d5 100644 --- a/google/cloud/gkemulticloud/v1/internal/attached_clusters_connection_impl.h +++ b/google/cloud/gkemulticloud/v1/internal/attached_clusters_connection_impl.h @@ -136,6 +136,18 @@ class AttachedClustersConnectionImpl google::cloud::gkemulticloud::v1:: GenerateAttachedClusterAgentTokenRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/gkemulticloud/v1/internal/attached_clusters_logging_decorator.cc b/google/cloud/gkemulticloud/v1/internal/attached_clusters_logging_decorator.cc index 926afa5e5b63d..f036ace8760f4 100644 --- a/google/cloud/gkemulticloud/v1/internal/attached_clusters_logging_decorator.cc +++ b/google/cloud/gkemulticloud/v1/internal/attached_clusters_logging_decorator.cc @@ -254,6 +254,51 @@ AttachedClustersLogging::GenerateAttachedClusterAgentToken( context, options, request, __func__, tracing_options_); } +StatusOr +AttachedClustersLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AttachedClustersLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AttachedClustersLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AttachedClustersLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> AttachedClustersLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/gkemulticloud/v1/internal/attached_clusters_logging_decorator.h b/google/cloud/gkemulticloud/v1/internal/attached_clusters_logging_decorator.h index c05d95f2ac3fa..41601b292649b 100644 --- a/google/cloud/gkemulticloud/v1/internal/attached_clusters_logging_decorator.h +++ b/google/cloud/gkemulticloud/v1/internal/attached_clusters_logging_decorator.h @@ -120,6 +120,22 @@ class AttachedClustersLogging : public AttachedClustersStub { google::cloud::gkemulticloud::v1:: GenerateAttachedClusterAgentTokenRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/gkemulticloud/v1/internal/attached_clusters_metadata_decorator.cc b/google/cloud/gkemulticloud/v1/internal/attached_clusters_metadata_decorator.cc index 2a937b41ee5cd..86feb109333cd 100644 --- a/google/cloud/gkemulticloud/v1/internal/attached_clusters_metadata_decorator.cc +++ b/google/cloud/gkemulticloud/v1/internal/attached_clusters_metadata_decorator.cc @@ -194,6 +194,39 @@ AttachedClustersMetadata::GenerateAttachedClusterAgentToken( return child_->GenerateAttachedClusterAgentToken(context, options, request); } +StatusOr +AttachedClustersMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr AttachedClustersMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status AttachedClustersMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status AttachedClustersMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + future> AttachedClustersMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/gkemulticloud/v1/internal/attached_clusters_metadata_decorator.h b/google/cloud/gkemulticloud/v1/internal/attached_clusters_metadata_decorator.h index 6e451ef0c7e22..4fd89d2e92e84 100644 --- a/google/cloud/gkemulticloud/v1/internal/attached_clusters_metadata_decorator.h +++ b/google/cloud/gkemulticloud/v1/internal/attached_clusters_metadata_decorator.h @@ -121,6 +121,22 @@ class AttachedClustersMetadata : public AttachedClustersStub { google::cloud::gkemulticloud::v1:: GenerateAttachedClusterAgentTokenRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/gkemulticloud/v1/internal/attached_clusters_stub.cc b/google/cloud/gkemulticloud/v1/internal/attached_clusters_stub.cc index e87fcc2307cfd..2d8143840f966 100644 --- a/google/cloud/gkemulticloud/v1/internal/attached_clusters_stub.cc +++ b/google/cloud/gkemulticloud/v1/internal/attached_clusters_stub.cc @@ -239,6 +239,52 @@ DefaultAttachedClustersStub::GenerateAttachedClusterAgentToken( return response; } +StatusOr +DefaultAttachedClustersStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAttachedClustersStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultAttachedClustersStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultAttachedClustersStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + future> DefaultAttachedClustersStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/gkemulticloud/v1/internal/attached_clusters_stub.h b/google/cloud/gkemulticloud/v1/internal/attached_clusters_stub.h index 57e6ee5e08035..4355434571947 100644 --- a/google/cloud/gkemulticloud/v1/internal/attached_clusters_stub.h +++ b/google/cloud/gkemulticloud/v1/internal/attached_clusters_stub.h @@ -123,6 +123,22 @@ class AttachedClustersStub { google::cloud::gkemulticloud::v1:: GenerateAttachedClusterAgentTokenRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -142,9 +158,13 @@ class DefaultAttachedClustersStub : public AttachedClustersStub { std::unique_ptr< google::cloud::gkemulticloud::v1::AttachedClusters::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateAttachedCluster( google::cloud::CompletionQueue& cq, @@ -227,6 +247,22 @@ class DefaultAttachedClustersStub : public AttachedClustersStub { google::cloud::gkemulticloud::v1:: GenerateAttachedClusterAgentTokenRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -243,6 +279,8 @@ class DefaultAttachedClustersStub : public AttachedClustersStub { std::unique_ptr< google::cloud::gkemulticloud::v1::AttachedClusters::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/gkemulticloud/v1/internal/attached_clusters_stub_factory.cc b/google/cloud/gkemulticloud/v1/internal/attached_clusters_stub_factory.cc index 5c3b9946a8e31..0e7b834491087 100644 --- a/google/cloud/gkemulticloud/v1/internal/attached_clusters_stub_factory.cc +++ b/google/cloud/gkemulticloud/v1/internal/attached_clusters_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 CreateDefaultAttachedClustersStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::gkemulticloud::v1::AttachedClusters::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/gkemulticloud/v1/internal/attached_clusters_tracing_connection.cc b/google/cloud/gkemulticloud/v1/internal/attached_clusters_tracing_connection.cc index f07153a3e0c47..c66551b2fa4c4 100644 --- a/google/cloud/gkemulticloud/v1/internal/attached_clusters_tracing_connection.cc +++ b/google/cloud/gkemulticloud/v1/internal/attached_clusters_tracing_connection.cc @@ -223,6 +223,42 @@ AttachedClustersTracingConnection::GenerateAttachedClusterAgentToken( child_->GenerateAttachedClusterAgentToken(request)); } +StreamRange +AttachedClustersTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "gkemulticloud_v1::AttachedClustersConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AttachedClustersTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "gkemulticloud_v1::AttachedClustersConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status AttachedClustersTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "gkemulticloud_v1::AttachedClustersConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status AttachedClustersTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "gkemulticloud_v1::AttachedClustersConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/gkemulticloud/v1/internal/attached_clusters_tracing_connection.h b/google/cloud/gkemulticloud/v1/internal/attached_clusters_tracing_connection.h index bcce5e9cd95a7..520e14e599ded 100644 --- a/google/cloud/gkemulticloud/v1/internal/attached_clusters_tracing_connection.h +++ b/google/cloud/gkemulticloud/v1/internal/attached_clusters_tracing_connection.h @@ -124,6 +124,18 @@ class AttachedClustersTracingConnection google::cloud::gkemulticloud::v1:: GenerateAttachedClusterAgentTokenRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/gkemulticloud/v1/internal/attached_clusters_tracing_stub.cc b/google/cloud/gkemulticloud/v1/internal/attached_clusters_tracing_stub.cc index 04ef9bf6ec453..eab7411ae8f87 100644 --- a/google/cloud/gkemulticloud/v1/internal/attached_clusters_tracing_stub.cc +++ b/google/cloud/gkemulticloud/v1/internal/attached_clusters_tracing_stub.cc @@ -229,6 +229,52 @@ AttachedClustersTracingStub::GenerateAttachedClusterAgentToken( child_->GenerateAttachedClusterAgentToken(context, options, request)); } +StatusOr +AttachedClustersTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.gkemulticloud.v1.AttachedClusters", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +AttachedClustersTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.gkemulticloud.v1.AttachedClusters", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status AttachedClustersTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.gkemulticloud.v1.AttachedClusters", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status AttachedClustersTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.gkemulticloud.v1.AttachedClusters", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + future> AttachedClustersTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/gkemulticloud/v1/internal/attached_clusters_tracing_stub.h b/google/cloud/gkemulticloud/v1/internal/attached_clusters_tracing_stub.h index 6c2a53e66704d..6f3167213db9e 100644 --- a/google/cloud/gkemulticloud/v1/internal/attached_clusters_tracing_stub.h +++ b/google/cloud/gkemulticloud/v1/internal/attached_clusters_tracing_stub.h @@ -120,6 +120,22 @@ class AttachedClustersTracingStub : public AttachedClustersStub { google::cloud::gkemulticloud::v1:: GenerateAttachedClusterAgentTokenRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/gkemulticloud/v1/internal/aws_clusters_auth_decorator.cc b/google/cloud/gkemulticloud/v1/internal/aws_clusters_auth_decorator.cc index a2205cecdc211..a0a593e64c6c2 100644 --- a/google/cloud/gkemulticloud/v1/internal/aws_clusters_auth_decorator.cc +++ b/google/cloud/gkemulticloud/v1/internal/aws_clusters_auth_decorator.cc @@ -315,6 +315,39 @@ AwsClustersAuth::GetAwsServerConfig( return child_->GetAwsServerConfig(context, options, request); } +StatusOr +AwsClustersAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr AwsClustersAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status AwsClustersAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status AwsClustersAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + future> AwsClustersAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/gkemulticloud/v1/internal/aws_clusters_auth_decorator.h b/google/cloud/gkemulticloud/v1/internal/aws_clusters_auth_decorator.h index e1ff1fcae2a37..701d6b13de85d 100644 --- a/google/cloud/gkemulticloud/v1/internal/aws_clusters_auth_decorator.h +++ b/google/cloud/gkemulticloud/v1/internal/aws_clusters_auth_decorator.h @@ -176,6 +176,22 @@ class AwsClustersAuth : public AwsClustersStub { google::cloud::gkemulticloud::v1::GetAwsServerConfigRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/gkemulticloud/v1/internal/aws_clusters_connection_impl.cc b/google/cloud/gkemulticloud/v1/internal/aws_clusters_connection_impl.cc index c1c91e0d3ebbe..c90875ac36aac 100644 --- a/google/cloud/gkemulticloud/v1/internal/aws_clusters_connection_impl.cc +++ b/google/cloud/gkemulticloud/v1/internal/aws_clusters_connection_impl.cc @@ -905,6 +905,79 @@ AwsClustersConnectionImpl::GetAwsServerConfig( *current, request, __func__); } +StreamRange +AwsClustersConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +AwsClustersConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status AwsClustersConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status AwsClustersConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace gkemulticloud_v1_internal } // namespace cloud diff --git a/google/cloud/gkemulticloud/v1/internal/aws_clusters_connection_impl.h b/google/cloud/gkemulticloud/v1/internal/aws_clusters_connection_impl.h index 583fa86350ed2..e7af3fa9bec0b 100644 --- a/google/cloud/gkemulticloud/v1/internal/aws_clusters_connection_impl.h +++ b/google/cloud/gkemulticloud/v1/internal/aws_clusters_connection_impl.h @@ -185,6 +185,18 @@ class AwsClustersConnectionImpl google::cloud::gkemulticloud::v1::GetAwsServerConfigRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/gkemulticloud/v1/internal/aws_clusters_logging_decorator.cc b/google/cloud/gkemulticloud/v1/internal/aws_clusters_logging_decorator.cc index cc0a5fb7e4784..179a782c9998f 100644 --- a/google/cloud/gkemulticloud/v1/internal/aws_clusters_logging_decorator.cc +++ b/google/cloud/gkemulticloud/v1/internal/aws_clusters_logging_decorator.cc @@ -377,6 +377,51 @@ AwsClustersLogging::GetAwsServerConfig( context, options, request, __func__, tracing_options_); } +StatusOr +AwsClustersLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AwsClustersLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AwsClustersLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AwsClustersLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> AwsClustersLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/gkemulticloud/v1/internal/aws_clusters_logging_decorator.h b/google/cloud/gkemulticloud/v1/internal/aws_clusters_logging_decorator.h index a5994bd31e274..bbe9600c70b0a 100644 --- a/google/cloud/gkemulticloud/v1/internal/aws_clusters_logging_decorator.h +++ b/google/cloud/gkemulticloud/v1/internal/aws_clusters_logging_decorator.h @@ -176,6 +176,22 @@ class AwsClustersLogging : public AwsClustersStub { google::cloud::gkemulticloud::v1::GetAwsServerConfigRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/gkemulticloud/v1/internal/aws_clusters_metadata_decorator.cc b/google/cloud/gkemulticloud/v1/internal/aws_clusters_metadata_decorator.cc index 2103888b5016a..659a7e9088046 100644 --- a/google/cloud/gkemulticloud/v1/internal/aws_clusters_metadata_decorator.cc +++ b/google/cloud/gkemulticloud/v1/internal/aws_clusters_metadata_decorator.cc @@ -282,6 +282,39 @@ AwsClustersMetadata::GetAwsServerConfig( return child_->GetAwsServerConfig(context, options, request); } +StatusOr +AwsClustersMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr AwsClustersMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status AwsClustersMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status AwsClustersMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + future> AwsClustersMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/gkemulticloud/v1/internal/aws_clusters_metadata_decorator.h b/google/cloud/gkemulticloud/v1/internal/aws_clusters_metadata_decorator.h index a9a538992420e..843c075fc3485 100644 --- a/google/cloud/gkemulticloud/v1/internal/aws_clusters_metadata_decorator.h +++ b/google/cloud/gkemulticloud/v1/internal/aws_clusters_metadata_decorator.h @@ -176,6 +176,22 @@ class AwsClustersMetadata : public AwsClustersStub { google::cloud::gkemulticloud::v1::GetAwsServerConfigRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/gkemulticloud/v1/internal/aws_clusters_stub.cc b/google/cloud/gkemulticloud/v1/internal/aws_clusters_stub.cc index 118ddf5427b9d..0dd2a3762d41e 100644 --- a/google/cloud/gkemulticloud/v1/internal/aws_clusters_stub.cc +++ b/google/cloud/gkemulticloud/v1/internal/aws_clusters_stub.cc @@ -366,6 +366,51 @@ DefaultAwsClustersStub::GetAwsServerConfig( return response; } +StatusOr +DefaultAwsClustersStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAwsClustersStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultAwsClustersStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultAwsClustersStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + future> DefaultAwsClustersStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/gkemulticloud/v1/internal/aws_clusters_stub.h b/google/cloud/gkemulticloud/v1/internal/aws_clusters_stub.h index 95efcf225b795..864750c55168c 100644 --- a/google/cloud/gkemulticloud/v1/internal/aws_clusters_stub.h +++ b/google/cloud/gkemulticloud/v1/internal/aws_clusters_stub.h @@ -183,6 +183,22 @@ class AwsClustersStub { google::cloud::gkemulticloud::v1::GetAwsServerConfigRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -202,9 +218,13 @@ class DefaultAwsClustersStub : public AwsClustersStub { std::unique_ptr< google::cloud::gkemulticloud::v1::AwsClusters::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateAwsCluster( google::cloud::CompletionQueue& cq, @@ -343,6 +363,22 @@ class DefaultAwsClustersStub : public AwsClustersStub { google::cloud::gkemulticloud::v1::GetAwsServerConfigRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -358,6 +394,8 @@ class DefaultAwsClustersStub : public AwsClustersStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/gkemulticloud/v1/internal/aws_clusters_stub_factory.cc b/google/cloud/gkemulticloud/v1/internal/aws_clusters_stub_factory.cc index 514040a9aef36..72f73d933847c 100644 --- a/google/cloud/gkemulticloud/v1/internal/aws_clusters_stub_factory.cc +++ b/google/cloud/gkemulticloud/v1/internal/aws_clusters_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 CreateDefaultAwsClustersStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::gkemulticloud::v1::AwsClusters::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/gkemulticloud/v1/internal/aws_clusters_tracing_connection.cc b/google/cloud/gkemulticloud/v1/internal/aws_clusters_tracing_connection.cc index d1428d04106e0..28db0f1acfa31 100644 --- a/google/cloud/gkemulticloud/v1/internal/aws_clusters_tracing_connection.cc +++ b/google/cloud/gkemulticloud/v1/internal/aws_clusters_tracing_connection.cc @@ -338,6 +338,42 @@ AwsClustersTracingConnection::GetAwsServerConfig( return internal::EndSpan(*span, child_->GetAwsServerConfig(request)); } +StreamRange +AwsClustersTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "gkemulticloud_v1::AwsClustersConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AwsClustersTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "gkemulticloud_v1::AwsClustersConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status AwsClustersTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "gkemulticloud_v1::AwsClustersConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status AwsClustersTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "gkemulticloud_v1::AwsClustersConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/gkemulticloud/v1/internal/aws_clusters_tracing_connection.h b/google/cloud/gkemulticloud/v1/internal/aws_clusters_tracing_connection.h index afefeea1495c1..3088dd3fdb166 100644 --- a/google/cloud/gkemulticloud/v1/internal/aws_clusters_tracing_connection.h +++ b/google/cloud/gkemulticloud/v1/internal/aws_clusters_tracing_connection.h @@ -173,6 +173,18 @@ class AwsClustersTracingConnection google::cloud::gkemulticloud::v1::GetAwsServerConfigRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/gkemulticloud/v1/internal/aws_clusters_tracing_stub.cc b/google/cloud/gkemulticloud/v1/internal/aws_clusters_tracing_stub.cc index a52290a900af5..e64946ef4bae2 100644 --- a/google/cloud/gkemulticloud/v1/internal/aws_clusters_tracing_stub.cc +++ b/google/cloud/gkemulticloud/v1/internal/aws_clusters_tracing_stub.cc @@ -339,6 +339,51 @@ AwsClustersTracingStub::GetAwsServerConfig( context, *span, child_->GetAwsServerConfig(context, options, request)); } +StatusOr +AwsClustersTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.gkemulticloud.v1.AwsClusters", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr AwsClustersTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.gkemulticloud.v1.AwsClusters", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status AwsClustersTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.gkemulticloud.v1.AwsClusters", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status AwsClustersTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.gkemulticloud.v1.AwsClusters", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + future> AwsClustersTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/gkemulticloud/v1/internal/aws_clusters_tracing_stub.h b/google/cloud/gkemulticloud/v1/internal/aws_clusters_tracing_stub.h index 083dfa8119513..47543c32eccd9 100644 --- a/google/cloud/gkemulticloud/v1/internal/aws_clusters_tracing_stub.h +++ b/google/cloud/gkemulticloud/v1/internal/aws_clusters_tracing_stub.h @@ -175,6 +175,22 @@ class AwsClustersTracingStub : public AwsClustersStub { google::cloud::gkemulticloud::v1::GetAwsServerConfigRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/gkemulticloud/v1/internal/azure_clusters_auth_decorator.cc b/google/cloud/gkemulticloud/v1/internal/azure_clusters_auth_decorator.cc index 38ea270b82a5f..6513c1bf3a639 100644 --- a/google/cloud/gkemulticloud/v1/internal/azure_clusters_auth_decorator.cc +++ b/google/cloud/gkemulticloud/v1/internal/azure_clusters_auth_decorator.cc @@ -373,6 +373,39 @@ AzureClustersAuth::GetAzureServerConfig( return child_->GetAzureServerConfig(context, options, request); } +StatusOr +AzureClustersAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr AzureClustersAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status AzureClustersAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status AzureClustersAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + future> AzureClustersAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/gkemulticloud/v1/internal/azure_clusters_auth_decorator.h b/google/cloud/gkemulticloud/v1/internal/azure_clusters_auth_decorator.h index 03b80afad9ad8..40e523e49b80f 100644 --- a/google/cloud/gkemulticloud/v1/internal/azure_clusters_auth_decorator.h +++ b/google/cloud/gkemulticloud/v1/internal/azure_clusters_auth_decorator.h @@ -199,6 +199,22 @@ class AzureClustersAuth : public AzureClustersStub { google::cloud::gkemulticloud::v1::GetAzureServerConfigRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/gkemulticloud/v1/internal/azure_clusters_connection_impl.cc b/google/cloud/gkemulticloud/v1/internal/azure_clusters_connection_impl.cc index 4e96f1d16e57e..45b63e198c361 100644 --- a/google/cloud/gkemulticloud/v1/internal/azure_clusters_connection_impl.cc +++ b/google/cloud/gkemulticloud/v1/internal/azure_clusters_connection_impl.cc @@ -1063,6 +1063,79 @@ AzureClustersConnectionImpl::GetAzureServerConfig( *current, request, __func__); } +StreamRange +AzureClustersConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +AzureClustersConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status AzureClustersConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status AzureClustersConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace gkemulticloud_v1_internal } // namespace cloud diff --git a/google/cloud/gkemulticloud/v1/internal/azure_clusters_connection_impl.h b/google/cloud/gkemulticloud/v1/internal/azure_clusters_connection_impl.h index 23c61767e3891..54059df5b4e00 100644 --- a/google/cloud/gkemulticloud/v1/internal/azure_clusters_connection_impl.h +++ b/google/cloud/gkemulticloud/v1/internal/azure_clusters_connection_impl.h @@ -206,6 +206,18 @@ class AzureClustersConnectionImpl google::cloud::gkemulticloud::v1::GetAzureServerConfigRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/gkemulticloud/v1/internal/azure_clusters_logging_decorator.cc b/google/cloud/gkemulticloud/v1/internal/azure_clusters_logging_decorator.cc index 14c6e04f01246..38021f53bd782 100644 --- a/google/cloud/gkemulticloud/v1/internal/azure_clusters_logging_decorator.cc +++ b/google/cloud/gkemulticloud/v1/internal/azure_clusters_logging_decorator.cc @@ -456,6 +456,51 @@ AzureClustersLogging::GetAzureServerConfig( context, options, request, __func__, tracing_options_); } +StatusOr +AzureClustersLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AzureClustersLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AzureClustersLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AzureClustersLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> AzureClustersLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/gkemulticloud/v1/internal/azure_clusters_logging_decorator.h b/google/cloud/gkemulticloud/v1/internal/azure_clusters_logging_decorator.h index 817c19391d8d5..c2fa1cedeb190 100644 --- a/google/cloud/gkemulticloud/v1/internal/azure_clusters_logging_decorator.h +++ b/google/cloud/gkemulticloud/v1/internal/azure_clusters_logging_decorator.h @@ -199,6 +199,22 @@ class AzureClustersLogging : public AzureClustersStub { google::cloud::gkemulticloud::v1::GetAzureServerConfigRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/gkemulticloud/v1/internal/azure_clusters_metadata_decorator.cc b/google/cloud/gkemulticloud/v1/internal/azure_clusters_metadata_decorator.cc index 94b261abd8860..f1770609da468 100644 --- a/google/cloud/gkemulticloud/v1/internal/azure_clusters_metadata_decorator.cc +++ b/google/cloud/gkemulticloud/v1/internal/azure_clusters_metadata_decorator.cc @@ -342,6 +342,39 @@ AzureClustersMetadata::GetAzureServerConfig( return child_->GetAzureServerConfig(context, options, request); } +StatusOr +AzureClustersMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr AzureClustersMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status AzureClustersMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status AzureClustersMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + future> AzureClustersMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/gkemulticloud/v1/internal/azure_clusters_metadata_decorator.h b/google/cloud/gkemulticloud/v1/internal/azure_clusters_metadata_decorator.h index 55532b661e7c9..15e846d3299df 100644 --- a/google/cloud/gkemulticloud/v1/internal/azure_clusters_metadata_decorator.h +++ b/google/cloud/gkemulticloud/v1/internal/azure_clusters_metadata_decorator.h @@ -199,6 +199,22 @@ class AzureClustersMetadata : public AzureClustersStub { google::cloud::gkemulticloud::v1::GetAzureServerConfigRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/gkemulticloud/v1/internal/azure_clusters_stub.cc b/google/cloud/gkemulticloud/v1/internal/azure_clusters_stub.cc index 9162980fd689f..417503980d85f 100644 --- a/google/cloud/gkemulticloud/v1/internal/azure_clusters_stub.cc +++ b/google/cloud/gkemulticloud/v1/internal/azure_clusters_stub.cc @@ -433,6 +433,51 @@ DefaultAzureClustersStub::GetAzureServerConfig( return response; } +StatusOr +DefaultAzureClustersStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAzureClustersStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultAzureClustersStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultAzureClustersStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + future> DefaultAzureClustersStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/gkemulticloud/v1/internal/azure_clusters_stub.h b/google/cloud/gkemulticloud/v1/internal/azure_clusters_stub.h index 71cbb6bd22d2c..0fb12baeb3ac1 100644 --- a/google/cloud/gkemulticloud/v1/internal/azure_clusters_stub.h +++ b/google/cloud/gkemulticloud/v1/internal/azure_clusters_stub.h @@ -209,6 +209,22 @@ class AzureClustersStub { google::cloud::gkemulticloud::v1::GetAzureServerConfigRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -228,9 +244,13 @@ class DefaultAzureClustersStub : public AzureClustersStub { std::unique_ptr< google::cloud::gkemulticloud::v1::AzureClusters::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateAzureClient( google::cloud::CompletionQueue& cq, @@ -392,6 +412,22 @@ class DefaultAzureClustersStub : public AzureClustersStub { google::cloud::gkemulticloud::v1::GetAzureServerConfigRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -408,6 +444,8 @@ class DefaultAzureClustersStub : public AzureClustersStub { std::unique_ptr< google::cloud::gkemulticloud::v1::AzureClusters::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/gkemulticloud/v1/internal/azure_clusters_stub_factory.cc b/google/cloud/gkemulticloud/v1/internal/azure_clusters_stub_factory.cc index 86542e7a97c4f..ae5fc16fc5c3b 100644 --- a/google/cloud/gkemulticloud/v1/internal/azure_clusters_stub_factory.cc +++ b/google/cloud/gkemulticloud/v1/internal/azure_clusters_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 CreateDefaultAzureClustersStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::gkemulticloud::v1::AzureClusters::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/gkemulticloud/v1/internal/azure_clusters_tracing_connection.cc b/google/cloud/gkemulticloud/v1/internal/azure_clusters_tracing_connection.cc index 2b3fcaf672133..6a238f10a9e51 100644 --- a/google/cloud/gkemulticloud/v1/internal/azure_clusters_tracing_connection.cc +++ b/google/cloud/gkemulticloud/v1/internal/azure_clusters_tracing_connection.cc @@ -407,6 +407,42 @@ AzureClustersTracingConnection::GetAzureServerConfig( return internal::EndSpan(*span, child_->GetAzureServerConfig(request)); } +StreamRange +AzureClustersTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "gkemulticloud_v1::AzureClustersConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AzureClustersTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "gkemulticloud_v1::AzureClustersConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status AzureClustersTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "gkemulticloud_v1::AzureClustersConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status AzureClustersTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "gkemulticloud_v1::AzureClustersConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/gkemulticloud/v1/internal/azure_clusters_tracing_connection.h b/google/cloud/gkemulticloud/v1/internal/azure_clusters_tracing_connection.h index c613eb0409477..cd07b735fa9fd 100644 --- a/google/cloud/gkemulticloud/v1/internal/azure_clusters_tracing_connection.h +++ b/google/cloud/gkemulticloud/v1/internal/azure_clusters_tracing_connection.h @@ -194,6 +194,18 @@ class AzureClustersTracingConnection google::cloud::gkemulticloud::v1::GetAzureServerConfigRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/gkemulticloud/v1/internal/azure_clusters_tracing_stub.cc b/google/cloud/gkemulticloud/v1/internal/azure_clusters_tracing_stub.cc index 3dd37193d0541..f438bddcfeba5 100644 --- a/google/cloud/gkemulticloud/v1/internal/azure_clusters_tracing_stub.cc +++ b/google/cloud/gkemulticloud/v1/internal/azure_clusters_tracing_stub.cc @@ -403,6 +403,51 @@ AzureClustersTracingStub::GetAzureServerConfig( context, *span, child_->GetAzureServerConfig(context, options, request)); } +StatusOr +AzureClustersTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.gkemulticloud.v1.AzureClusters", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr AzureClustersTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.gkemulticloud.v1.AzureClusters", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status AzureClustersTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.gkemulticloud.v1.AzureClusters", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status AzureClustersTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.gkemulticloud.v1.AzureClusters", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + future> AzureClustersTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/gkemulticloud/v1/internal/azure_clusters_tracing_stub.h b/google/cloud/gkemulticloud/v1/internal/azure_clusters_tracing_stub.h index 7ce0688982a29..7dfd868eef17a 100644 --- a/google/cloud/gkemulticloud/v1/internal/azure_clusters_tracing_stub.h +++ b/google/cloud/gkemulticloud/v1/internal/azure_clusters_tracing_stub.h @@ -198,6 +198,22 @@ class AzureClustersTracingStub : public AzureClustersStub { google::cloud::gkemulticloud::v1::GetAzureServerConfigRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/gkemulticloud/v1/mocks/mock_attached_clusters_connection.h b/google/cloud/gkemulticloud/v1/mocks/mock_attached_clusters_connection.h index 8e114760c052a..c919bb5ebbf5c 100644 --- a/google/cloud/gkemulticloud/v1/mocks/mock_attached_clusters_connection.h +++ b/google/cloud/gkemulticloud/v1/mocks/mock_attached_clusters_connection.h @@ -249,6 +249,21 @@ class MockAttachedClustersConnection (google::cloud::gkemulticloud::v1:: GenerateAttachedClusterAgentTokenRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/gkemulticloud/v1/mocks/mock_aws_clusters_connection.h b/google/cloud/gkemulticloud/v1/mocks/mock_aws_clusters_connection.h index 24ed867648e6f..f2ad067a8c7a0 100644 --- a/google/cloud/gkemulticloud/v1/mocks/mock_aws_clusters_connection.h +++ b/google/cloud/gkemulticloud/v1/mocks/mock_aws_clusters_connection.h @@ -383,6 +383,21 @@ class MockAwsClustersConnection (google::cloud::gkemulticloud::v1::GetAwsServerConfigRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/gkemulticloud/v1/mocks/mock_azure_clusters_connection.h b/google/cloud/gkemulticloud/v1/mocks/mock_azure_clusters_connection.h index 41659c327b496..7197546da973e 100644 --- a/google/cloud/gkemulticloud/v1/mocks/mock_azure_clusters_connection.h +++ b/google/cloud/gkemulticloud/v1/mocks/mock_azure_clusters_connection.h @@ -444,6 +444,21 @@ class MockAzureClustersConnection (google::cloud::gkemulticloud::v1::GetAzureServerConfigRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/iam/v2/internal/policies_auth_decorator.cc b/google/cloud/iam/v2/internal/policies_auth_decorator.cc index cd5ec7f451d9e..af9f6d2f7218c 100644 --- a/google/cloud/iam/v2/internal/policies_auth_decorator.cc +++ b/google/cloud/iam/v2/internal/policies_auth_decorator.cc @@ -131,6 +131,14 @@ StatusOr PoliciesAuth::DeletePolicy( return child_->DeletePolicy(context, options, request); } +StatusOr PoliciesAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + future> PoliciesAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/iam/v2/internal/policies_auth_decorator.h b/google/cloud/iam/v2/internal/policies_auth_decorator.h index 63cd026ee5351..a17107127e74e 100644 --- a/google/cloud/iam/v2/internal/policies_auth_decorator.h +++ b/google/cloud/iam/v2/internal/policies_auth_decorator.h @@ -77,6 +77,10 @@ class PoliciesAuth : public PoliciesStub { grpc::ClientContext& context, Options options, google::iam::v2::DeletePolicyRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/iam/v2/internal/policies_connection_impl.cc b/google/cloud/iam/v2/internal/policies_connection_impl.cc index bc474ebeb0785..dfafd915117e0 100644 --- a/google/cloud/iam/v2/internal/policies_connection_impl.cc +++ b/google/cloud/iam/v2/internal/policies_connection_impl.cc @@ -361,6 +361,19 @@ future> PoliciesConnectionImpl::DeletePolicy( polling_policy(*current), __func__); } +StatusOr PoliciesConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace iam_v2_internal } // namespace cloud diff --git a/google/cloud/iam/v2/internal/policies_connection_impl.h b/google/cloud/iam/v2/internal/policies_connection_impl.h index eb902ee968963..e8359f1e3cf05 100644 --- a/google/cloud/iam/v2/internal/policies_connection_impl.h +++ b/google/cloud/iam/v2/internal/policies_connection_impl.h @@ -83,6 +83,9 @@ class PoliciesConnectionImpl : public iam_v2::PoliciesConnection { future> DeletePolicy( google::longrunning::Operation const& operation) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/iam/v2/internal/policies_logging_decorator.cc b/google/cloud/iam/v2/internal/policies_logging_decorator.cc index 6ccd88ea6e1fb..f2089d6ea058f 100644 --- a/google/cloud/iam/v2/internal/policies_logging_decorator.cc +++ b/google/cloud/iam/v2/internal/policies_logging_decorator.cc @@ -144,6 +144,17 @@ StatusOr PoliciesLogging::DeletePolicy( context, options, request, __func__, tracing_options_); } +StatusOr PoliciesLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> PoliciesLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/iam/v2/internal/policies_logging_decorator.h b/google/cloud/iam/v2/internal/policies_logging_decorator.h index b178f7b0fd14f..20aaaee39f299 100644 --- a/google/cloud/iam/v2/internal/policies_logging_decorator.h +++ b/google/cloud/iam/v2/internal/policies_logging_decorator.h @@ -77,6 +77,10 @@ class PoliciesLogging : public PoliciesStub { grpc::ClientContext& context, Options options, google::iam::v2::DeletePolicyRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/iam/v2/internal/policies_metadata_decorator.cc b/google/cloud/iam/v2/internal/policies_metadata_decorator.cc index b03ff3685fb13..b2e38d4e46d44 100644 --- a/google/cloud/iam/v2/internal/policies_metadata_decorator.cc +++ b/google/cloud/iam/v2/internal/policies_metadata_decorator.cc @@ -122,6 +122,14 @@ StatusOr PoliciesMetadata::DeletePolicy( return child_->DeletePolicy(context, options, request); } +StatusOr PoliciesMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + future> PoliciesMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/iam/v2/internal/policies_metadata_decorator.h b/google/cloud/iam/v2/internal/policies_metadata_decorator.h index 4a3f18e0d5f84..3144b3f5ddd6b 100644 --- a/google/cloud/iam/v2/internal/policies_metadata_decorator.h +++ b/google/cloud/iam/v2/internal/policies_metadata_decorator.h @@ -77,6 +77,10 @@ class PoliciesMetadata : public PoliciesStub { grpc::ClientContext& context, Options options, google::iam::v2::DeletePolicyRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/iam/v2/internal/policies_stub.cc b/google/cloud/iam/v2/internal/policies_stub.cc index 7905225563d74..9dd1fc16411ed 100644 --- a/google/cloud/iam/v2/internal/policies_stub.cc +++ b/google/cloud/iam/v2/internal/policies_stub.cc @@ -138,6 +138,17 @@ StatusOr DefaultPoliciesStub::DeletePolicy( return response; } +StatusOr DefaultPoliciesStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultPoliciesStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/iam/v2/internal/policies_stub.h b/google/cloud/iam/v2/internal/policies_stub.h index 1f7d6f5245e56..480003b9110f6 100644 --- a/google/cloud/iam/v2/internal/policies_stub.h +++ b/google/cloud/iam/v2/internal/policies_stub.h @@ -76,6 +76,10 @@ class PoliciesStub { grpc::ClientContext& context, Options options, google::iam::v2::DeletePolicyRequest const& request) = 0; + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -93,9 +97,13 @@ class DefaultPoliciesStub : public PoliciesStub { public: DefaultPoliciesStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr ListPolicies( grpc::ClientContext& context, Options const& options, @@ -135,6 +143,10 @@ class DefaultPoliciesStub : public PoliciesStub { grpc::ClientContext& context, Options options, google::iam::v2::DeletePolicyRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -149,6 +161,8 @@ class DefaultPoliciesStub : public PoliciesStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/iam/v2/internal/policies_stub_factory.cc b/google/cloud/iam/v2/internal/policies_stub_factory.cc index 0c5e82345fbbc..9080d90641b7e 100644 --- a/google/cloud/iam/v2/internal/policies_stub_factory.cc +++ b/google/cloud/iam/v2/internal/policies_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -43,8 +44,10 @@ std::shared_ptr CreateDefaultPoliciesStub( auto channel = auth->CreateChannel(options.get(), internal::MakeChannelArguments(options)); auto service_grpc_stub = google::iam::v2::Policies::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/iam/v2/internal/policies_tracing_connection.cc b/google/cloud/iam/v2/internal/policies_tracing_connection.cc index 57183f6fee634..82c488c45ec00 100644 --- a/google/cloud/iam/v2/internal/policies_tracing_connection.cc +++ b/google/cloud/iam/v2/internal/policies_tracing_connection.cc @@ -121,6 +121,14 @@ PoliciesTracingConnection::DeletePolicy( return internal::EndSpan(std::move(span), child_->DeletePolicy(operation)); } +StatusOr +PoliciesTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan("iam_v2::PoliciesConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakePoliciesTracingConnection( diff --git a/google/cloud/iam/v2/internal/policies_tracing_connection.h b/google/cloud/iam/v2/internal/policies_tracing_connection.h index bc06c4d0b54f4..8f7c74bd5a0c1 100644 --- a/google/cloud/iam/v2/internal/policies_tracing_connection.h +++ b/google/cloud/iam/v2/internal/policies_tracing_connection.h @@ -72,6 +72,9 @@ class PoliciesTracingConnection : public iam_v2::PoliciesConnection { future> DeletePolicy( google::longrunning::Operation const& operation) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/iam/v2/internal/policies_tracing_stub.cc b/google/cloud/iam/v2/internal/policies_tracing_stub.cc index 70c84bea06c43..bfc1c57ce57d8 100644 --- a/google/cloud/iam/v2/internal/policies_tracing_stub.cc +++ b/google/cloud/iam/v2/internal/policies_tracing_stub.cc @@ -121,6 +121,16 @@ StatusOr PoliciesTracingStub::DeletePolicy( child_->DeletePolicy(context, options, request)); } +StatusOr PoliciesTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.iam.v2.Policies", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + future> PoliciesTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/iam/v2/internal/policies_tracing_stub.h b/google/cloud/iam/v2/internal/policies_tracing_stub.h index 7592b671ea38c..90b49071b1f8d 100644 --- a/google/cloud/iam/v2/internal/policies_tracing_stub.h +++ b/google/cloud/iam/v2/internal/policies_tracing_stub.h @@ -76,6 +76,10 @@ class PoliciesTracingStub : public PoliciesStub { grpc::ClientContext& context, Options options, google::iam::v2::DeletePolicyRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/iam/v2/mocks/mock_policies_connection.h b/google/cloud/iam/v2/mocks/mock_policies_connection.h index 024b1a76c11fb..886eaf3298d45 100644 --- a/google/cloud/iam/v2/mocks/mock_policies_connection.h +++ b/google/cloud/iam/v2/mocks/mock_policies_connection.h @@ -150,6 +150,10 @@ class MockPoliciesConnection : public iam_v2::PoliciesConnection { /// @endcode MOCK_METHOD(future>, DeletePolicy, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/iam/v2/policies_client.cc b/google/cloud/iam/v2/policies_client.cc index 5b3767cf91f86..c21ebbd834fd3 100644 --- a/google/cloud/iam/v2/policies_client.cc +++ b/google/cloud/iam/v2/policies_client.cc @@ -156,6 +156,20 @@ future> PoliciesClient::DeletePolicy( return connection_->DeletePolicy(operation); } +StatusOr PoliciesClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr PoliciesClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace iam_v2 } // namespace cloud diff --git a/google/cloud/iam/v2/policies_client.h b/google/cloud/iam/v2/policies_client.h index 30bdebc864682..bb5a32602d341 100644 --- a/google/cloud/iam/v2/policies_client.h +++ b/google/cloud/iam/v2/policies_client.h @@ -561,6 +561,66 @@ class PoliciesClient { future> DeletePolicy( google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/iam/v2/policies_connection.cc b/google/cloud/iam/v2/policies_connection.cc index eb8a8bbeb3090..30df6060b9d83 100644 --- a/google/cloud/iam/v2/policies_connection.cc +++ b/google/cloud/iam/v2/policies_connection.cc @@ -104,6 +104,11 @@ future> PoliciesConnection::DeletePolicy( Status(StatusCode::kUnimplemented, "not implemented")); } +StatusOr PoliciesConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakePoliciesConnection(Options options) { internal::CheckExpectedOptions> DeletePolicy( google::longrunning::Operation const& operation); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/iam/v2/policies_connection_idempotency_policy.cc b/google/cloud/iam/v2/policies_connection_idempotency_policy.cc index 9f117b89cd40b..cea197988f25c 100644 --- a/google/cloud/iam/v2/policies_connection_idempotency_policy.cc +++ b/google/cloud/iam/v2/policies_connection_idempotency_policy.cc @@ -59,6 +59,11 @@ Idempotency PoliciesConnectionIdempotencyPolicy::DeletePolicy( return Idempotency::kNonIdempotent; } +Idempotency PoliciesConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultPoliciesConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/iam/v2/policies_connection_idempotency_policy.h b/google/cloud/iam/v2/policies_connection_idempotency_policy.h index 412b0fabe613e..611fc49d61c21 100644 --- a/google/cloud/iam/v2/policies_connection_idempotency_policy.h +++ b/google/cloud/iam/v2/policies_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,9 @@ class PoliciesConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeletePolicy( google::iam::v2::DeletePolicyRequest const& request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr 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..814afd66185eb 100644 --- a/google/cloud/kms/v1/autokey_admin_client.cc +++ b/google/cloud/kms/v1/autokey_admin_client.cc @@ -84,6 +84,52 @@ 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); +} + +StatusOr AutokeyAdminClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr AutokeyAdminClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(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..dcb1f6b8ecd17 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,238 @@ 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 = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest 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..3319deeefb8e0 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,40 @@ 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"); +} + +StatusOr AutokeyAdminConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeAutokeyAdminConnection( Options options) { internal::CheckExpectedOptions #include @@ -190,6 +191,24 @@ 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); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest 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..78e298ecc94fe 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,37 @@ 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; +} + +Idempotency AutokeyAdminConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest 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..774d82141df41 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,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -45,6 +48,24 @@ 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); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest 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..4af40e479dd55 100644 --- a/google/cloud/kms/v1/autokey_client.cc +++ b/google/cloud/kms/v1/autokey_client.cc @@ -109,6 +109,51 @@ 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); +} + +StatusOr AutokeyClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr AutokeyClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(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..1c8cf38f41981 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,238 @@ 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 = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest 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..eeff727bb99dd 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,39 @@ 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"); +} + +StatusOr AutokeyConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeAutokeyConnection(Options options) { internal::CheckExpectedOptions #include @@ -197,6 +198,24 @@ 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); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest 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..d3d5b12069e64 100644 --- a/google/cloud/kms/v1/autokey_connection_idempotency_policy.cc +++ b/google/cloud/kms/v1/autokey_connection_idempotency_policy.cc @@ -49,6 +49,37 @@ 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; +} + +Idempotency AutokeyConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest 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..ba305f8072267 100644 --- a/google/cloud/kms/v1/autokey_connection_idempotency_policy.h +++ b/google/cloud/kms/v1/autokey_connection_idempotency_policy.h @@ -22,6 +22,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -44,6 +47,24 @@ 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); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest 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..ec4b4ae771f15 100644 --- a/google/cloud/kms/v1/ekm_client.cc +++ b/google/cloud/kms/v1/ekm_client.cc @@ -149,6 +149,51 @@ 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); +} + +StatusOr EkmServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr EkmServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(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..41fe5f90cf0dc 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,238 @@ 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 = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest 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..e162cc9dce400 100644 --- a/google/cloud/kms/v1/ekm_connection.cc +++ b/google/cloud/kms/v1/ekm_connection.cc @@ -81,6 +81,40 @@ 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"); +} + +StatusOr EkmServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeEkmServiceConnection( Options options) { internal::CheckExpectedOptions 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); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest 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..91a47bd4508f8 100644 --- a/google/cloud/kms/v1/ekm_connection_idempotency_policy.cc +++ b/google/cloud/kms/v1/ekm_connection_idempotency_policy.cc @@ -69,6 +69,37 @@ 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; +} + +Idempotency EkmServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest 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..537cb2d02ae6a 100644 --- a/google/cloud/kms/v1/ekm_connection_idempotency_policy.h +++ b/google/cloud/kms/v1/ekm_connection_idempotency_policy.h @@ -22,6 +22,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -56,6 +59,24 @@ 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); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest 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..e3e60c08619e9 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,56 @@ 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); +} + +StatusOr AutokeyAdminAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(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..1f25b3c20c2b9 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,30 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..2afa63b755b65 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,108 @@ 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__); +} + +StatusOr +AutokeyAdminConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(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..286b1765127f3 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,24 @@ 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; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest 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..7de8149529332 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,74 @@ 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_); +} + +StatusOr AutokeyAdminLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(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..7f6d97aa7d8ea 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,30 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..7228b2bbdac5b 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,59 @@ 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); +} + +StatusOr AutokeyAdminMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(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..ebed32e4827ac 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,30 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..4acd378b6659c 100644 --- a/google/cloud/kms/v1/internal/autokey_admin_stub.cc +++ b/google/cloud/kms/v1/internal/autokey_admin_stub.cc @@ -67,6 +67,76 @@ 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; +} + +StatusOr DefaultAutokeyAdminStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&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..f66b56cc700bb 100644 --- a/google/cloud/kms/v1/internal/autokey_admin_stub.h +++ b/google/cloud/kms/v1/internal/autokey_admin_stub.h @@ -23,6 +23,9 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include #include #include @@ -48,14 +51,48 @@ 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; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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 + operations_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr UpdateAutokeyConfig( grpc::ClientContext& context, Options const& options, @@ -72,9 +109,38 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..2ff210eb74523 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,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,8 +47,15 @@ std::shared_ptr CreateDefaultAutokeyAdminStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::kms::v1::AutokeyAdmin::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..7f85c345c603c 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,59 @@ 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)); +} + +StatusOr +AutokeyAdminTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("kms_v1::AutokeyAdminConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(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..d8e98bc777852 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,24 @@ 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; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest 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..274dd92d29004 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,75 @@ 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)); +} + +StatusOr AutokeyAdminTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.kms.v1.AutokeyAdmin", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(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..07afb0fc6b378 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,30 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..c90277179f0f2 100644 --- a/google/cloud/kms/v1/internal/autokey_auth_decorator.cc +++ b/google/cloud/kms/v1/internal/autokey_auth_decorator.cc @@ -76,6 +76,56 @@ 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); +} + +StatusOr AutokeyAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(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..0ef61b1b85f86 100644 --- a/google/cloud/kms/v1/internal/autokey_auth_decorator.h +++ b/google/cloud/kms/v1/internal/autokey_auth_decorator.h @@ -57,6 +57,30 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..abb842eff09c4 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,106 @@ 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__); +} + +StatusOr AutokeyConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(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..97027be50a305 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,24 @@ 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; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest 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..a5d03d0369c65 100644 --- a/google/cloud/kms/v1/internal/autokey_logging_decorator.cc +++ b/google/cloud/kms/v1/internal/autokey_logging_decorator.cc @@ -87,6 +87,74 @@ 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_); +} + +StatusOr AutokeyLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(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..756005fe77bde 100644 --- a/google/cloud/kms/v1/internal/autokey_logging_decorator.h +++ b/google/cloud/kms/v1/internal/autokey_logging_decorator.h @@ -57,6 +57,30 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..e57cd9ee68356 100644 --- a/google/cloud/kms/v1/internal/autokey_metadata_decorator.cc +++ b/google/cloud/kms/v1/internal/autokey_metadata_decorator.cc @@ -81,6 +81,59 @@ 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); +} + +StatusOr AutokeyMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(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..0841c01f94c79 100644 --- a/google/cloud/kms/v1/internal/autokey_metadata_decorator.h +++ b/google/cloud/kms/v1/internal/autokey_metadata_decorator.h @@ -57,6 +57,30 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..061a98c3bae53 100644 --- a/google/cloud/kms/v1/internal/autokey_stub.cc +++ b/google/cloud/kms/v1/internal/autokey_stub.cc @@ -83,6 +83,75 @@ 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; +} + +StatusOr DefaultAutokeyStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&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..8a8329ed3d20f 100644 --- a/google/cloud/kms/v1/internal/autokey_stub.h +++ b/google/cloud/kms/v1/internal/autokey_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -57,6 +59,32 @@ 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 StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -74,9 +102,18 @@ class DefaultAutokeyStub : public AutokeyStub { public: DefaultAutokeyStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +133,30 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -110,6 +171,11 @@ class DefaultAutokeyStub : public AutokeyStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..5be68fdc32071 100644 --- a/google/cloud/kms/v1/internal/autokey_stub_factory.cc +++ b/google/cloud/kms/v1/internal/autokey_stub_factory.cc @@ -29,6 +29,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -43,8 +46,14 @@ 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_operations_stub = + google::longrunning::Operations::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_operations_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..b971e5ad2fba0 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,54 @@ 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)); +} + +StatusOr AutokeyTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan("kms_v1::AutokeyConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(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..a6403b2121985 100644 --- a/google/cloud/kms/v1/internal/autokey_tracing_connection.h +++ b/google/cloud/kms/v1/internal/autokey_tracing_connection.h @@ -55,6 +55,24 @@ 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; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest 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..b06fccc5b9492 100644 --- a/google/cloud/kms/v1/internal/autokey_tracing_stub.cc +++ b/google/cloud/kms/v1/internal/autokey_tracing_stub.cc @@ -80,6 +80,74 @@ 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)); +} + +StatusOr AutokeyTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.kms.v1.Autokey", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(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..8dff65aa5e343 100644 --- a/google/cloud/kms/v1/internal/autokey_tracing_stub.h +++ b/google/cloud/kms/v1/internal/autokey_tracing_stub.h @@ -56,6 +56,30 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..d938658d47e21 100644 --- a/google/cloud/kms/v1/internal/ekm_auth_decorator.cc +++ b/google/cloud/kms/v1/internal/ekm_auth_decorator.cc @@ -92,6 +92,56 @@ 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); +} + +StatusOr EkmServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(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..b2b46fbc4eb03 100644 --- a/google/cloud/kms/v1/internal/ekm_auth_decorator.h +++ b/google/cloud/kms/v1/internal/ekm_auth_decorator.h @@ -70,6 +70,30 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..c18d1b0202ef3 100644 --- a/google/cloud/kms/v1/internal/ekm_connection_impl.cc +++ b/google/cloud/kms/v1/internal/ekm_connection_impl.cc @@ -177,6 +177,107 @@ 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__); +} + +StatusOr EkmServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(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..069206a192964 100644 --- a/google/cloud/kms/v1/internal/ekm_connection_impl.h +++ b/google/cloud/kms/v1/internal/ekm_connection_impl.h @@ -71,6 +71,24 @@ 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; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest 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..43b35baad20ac 100644 --- a/google/cloud/kms/v1/internal/ekm_logging_decorator.cc +++ b/google/cloud/kms/v1/internal/ekm_logging_decorator.cc @@ -119,6 +119,74 @@ 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_); +} + +StatusOr EkmServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(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..6bb2dade995f9 100644 --- a/google/cloud/kms/v1/internal/ekm_logging_decorator.h +++ b/google/cloud/kms/v1/internal/ekm_logging_decorator.h @@ -70,6 +70,30 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..1816c2a1091f2 100644 --- a/google/cloud/kms/v1/internal/ekm_metadata_decorator.cc +++ b/google/cloud/kms/v1/internal/ekm_metadata_decorator.cc @@ -108,6 +108,59 @@ 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); +} + +StatusOr EkmServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(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..7960f7f782e43 100644 --- a/google/cloud/kms/v1/internal/ekm_metadata_decorator.h +++ b/google/cloud/kms/v1/internal/ekm_metadata_decorator.h @@ -70,6 +70,30 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..1d887b62d66a5 100644 --- a/google/cloud/kms/v1/internal/ekm_stub.cc +++ b/google/cloud/kms/v1/internal/ekm_stub.cc @@ -113,6 +113,75 @@ 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; +} + +StatusOr DefaultEkmServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&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..77a341dac70e0 100644 --- a/google/cloud/kms/v1/internal/ekm_stub.h +++ b/google/cloud/kms/v1/internal/ekm_stub.h @@ -23,6 +23,9 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include #include #include @@ -64,14 +67,48 @@ 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; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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 + operations_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListEkmConnections(grpc::ClientContext& context, Options const& options, @@ -105,8 +142,37 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..3ec23155be229 100644 --- a/google/cloud/kms/v1/internal/ekm_stub_factory.cc +++ b/google/cloud/kms/v1/internal/ekm_stub_factory.cc @@ -29,6 +29,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -43,8 +46,15 @@ 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_operations_stub = + google::longrunning::Operations::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_operations_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..086e949b03ce3 100644 --- a/google/cloud/kms/v1/internal/ekm_tracing_connection.cc +++ b/google/cloud/kms/v1/internal/ekm_tracing_connection.cc @@ -97,6 +97,55 @@ 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)); +} + +StatusOr +EkmServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan("kms_v1::EkmServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(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..62d761d8fc37f 100644 --- a/google/cloud/kms/v1/internal/ekm_tracing_connection.h +++ b/google/cloud/kms/v1/internal/ekm_tracing_connection.h @@ -63,6 +63,24 @@ 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; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest 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..61421ad64ff3c 100644 --- a/google/cloud/kms/v1/internal/ekm_tracing_stub.cc +++ b/google/cloud/kms/v1/internal/ekm_tracing_stub.cc @@ -115,6 +115,74 @@ 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)); +} + +StatusOr EkmServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.kms.v1.EkmService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(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..69ed85e476074 100644 --- a/google/cloud/kms/v1/internal/ekm_tracing_stub.h +++ b/google/cloud/kms/v1/internal/ekm_tracing_stub.h @@ -70,6 +70,30 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..aa4b6bc3873a1 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,57 @@ 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); +} + +StatusOr KeyManagementServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(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..40e08757e3bac 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,30 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..0efab44046caf 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,110 @@ 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__); +} + +StatusOr +KeyManagementServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(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..483c23800fb37 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,24 @@ 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; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest 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..dbad8a547ff33 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,76 @@ 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_); +} + +StatusOr +KeyManagementServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(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..2625e65ac52a0 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,30 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..272d25cce91b1 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,61 @@ 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); +} + +StatusOr +KeyManagementServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(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..7031678650e74 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,30 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..d317d3dc10e11 100644 --- a/google/cloud/kms/v1/internal/key_management_stub.cc +++ b/google/cloud/kms/v1/internal/key_management_stub.cc @@ -373,6 +373,77 @@ 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; +} + +StatusOr +DefaultKeyManagementServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&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..d21afb22ae7b3 100644 --- a/google/cloud/kms/v1/internal/key_management_stub.h +++ b/google/cloud/kms/v1/internal/key_management_stub.h @@ -23,6 +23,9 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include #include #include @@ -162,6 +165,32 @@ 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; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; }; class DefaultKeyManagementServiceStub : public KeyManagementServiceStub { @@ -169,8 +198,16 @@ 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 + operations_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListKeyRings( grpc::ClientContext& context, Options const& options, @@ -294,9 +331,38 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..a83adfd1774de 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,9 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultKeyManagementServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::kms::v1::KeyManagementService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..9ac1b41f34731 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,62 @@ 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)); +} + +StatusOr +KeyManagementServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "kms_v1::KeyManagementServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(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..b3720ea2187bd 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,24 @@ 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; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest 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..ae4fc6e4db044 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,76 @@ 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)); +} + +StatusOr +KeyManagementServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.kms.v1.KeyManagementService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(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..54b67f954e7fb 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,30 @@ 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; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..043d4a69077f0 100644 --- a/google/cloud/kms/v1/key_management_client.cc +++ b/google/cloud/kms/v1/key_management_client.cc @@ -499,6 +499,55 @@ 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); +} + +StatusOr +KeyManagementServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +KeyManagementServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(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..ceede457e2487 100644 --- a/google/cloud/kms/v1/key_management_client.h +++ b/google/cloud/kms/v1/key_management_client.h @@ -2092,6 +2092,238 @@ 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 = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest 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..679fda0d9f81b 100644 --- a/google/cloud/kms/v1/key_management_connection.cc +++ b/google/cloud/kms/v1/key_management_connection.cc @@ -214,6 +214,42 @@ 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"); +} + +StatusOr +KeyManagementServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeKeyManagementServiceConnection(Options options) { internal::CheckExpectedOptions 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); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest 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..e1525a6a660c2 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,37 @@ 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; +} + +Idempotency KeyManagementServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest 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..b81091bcd2169 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,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include +#include #include namespace google { @@ -121,6 +124,24 @@ 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); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest 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..1081db88c4861 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,31 @@ 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)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest 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..d3257054c875b 100644 --- a/google/cloud/kms/v1/mocks/mock_autokey_connection.h +++ b/google/cloud/kms/v1/mocks/mock_autokey_connection.h @@ -91,6 +91,31 @@ 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)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest 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..df77727f715f1 100644 --- a/google/cloud/kms/v1/mocks/mock_ekm_connection.h +++ b/google/cloud/kms/v1/mocks/mock_ekm_connection.h @@ -78,6 +78,31 @@ 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)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest 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..cd67fd0af3f5c 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,31 @@ 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)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/logging/v2/config_service_v2_client.cc b/google/cloud/logging/v2/config_service_v2_client.cc index 2ceb778a4af94..b41eaa1c398f4 100644 --- a/google/cloud/logging/v2/config_service_v2_client.cc +++ b/google/cloud/logging/v2/config_service_v2_client.cc @@ -496,6 +496,51 @@ ConfigServiceV2Client::CopyLogEntries( return connection_->CopyLogEntries(operation); } +StreamRange +ConfigServiceV2Client::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +ConfigServiceV2Client::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr ConfigServiceV2Client::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr ConfigServiceV2Client::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status ConfigServiceV2Client::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status ConfigServiceV2Client::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace logging_v2 } // namespace cloud diff --git a/google/cloud/logging/v2/config_service_v2_client.h b/google/cloud/logging/v2/config_service_v2_client.h index e8682676bac7c..17eb387508724 100644 --- a/google/cloud/logging/v2/config_service_v2_client.h +++ b/google/cloud/logging/v2/config_service_v2_client.h @@ -2149,6 +2149,231 @@ class ConfigServiceV2Client { future> CopyLogEntries( google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/logging/v2/config_service_v2_connection.cc b/google/cloud/logging/v2/config_service_v2_connection.cc index 7d6e3c734c7cd..5ab4064cdd95d 100644 --- a/google/cloud/logging/v2/config_service_v2_connection.cc +++ b/google/cloud/logging/v2/config_service_v2_connection.cc @@ -302,6 +302,25 @@ ConfigServiceV2Connection::CopyLogEntries( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +ConfigServiceV2Connection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +ConfigServiceV2Connection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ConfigServiceV2Connection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeConfigServiceV2Connection( Options options) { internal::CheckExpectedOptions> CopyLogEntries(google::longrunning::Operation const& operation); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/logging/v2/config_service_v2_connection_idempotency_policy.cc b/google/cloud/logging/v2/config_service_v2_connection_idempotency_policy.cc index 8000130ba291c..af57f264895fb 100644 --- a/google/cloud/logging/v2/config_service_v2_connection_idempotency_policy.cc +++ b/google/cloud/logging/v2/config_service_v2_connection_idempotency_policy.cc @@ -194,6 +194,21 @@ Idempotency ConfigServiceV2ConnectionIdempotencyPolicy::CopyLogEntries( return Idempotency::kNonIdempotent; } +Idempotency ConfigServiceV2ConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ConfigServiceV2ConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ConfigServiceV2ConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultConfigServiceV2ConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/logging/v2/config_service_v2_connection_idempotency_policy.h b/google/cloud/logging/v2/config_service_v2_connection_idempotency_policy.h index 66178582a0af3..b086d4515e0e4 100644 --- a/google/cloud/logging/v2/config_service_v2_connection_idempotency_policy.h +++ b/google/cloud/logging/v2/config_service_v2_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -132,6 +133,15 @@ class ConfigServiceV2ConnectionIdempotencyPolicy { virtual google::cloud::Idempotency CopyLogEntries( google::logging::v2::CopyLogEntriesRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/logging/v2/internal/config_service_v2_auth_decorator.cc b/google/cloud/logging/v2/internal/config_service_v2_auth_decorator.cc index 618550264a871..a41e88d6074c6 100644 --- a/google/cloud/logging/v2/internal/config_service_v2_auth_decorator.cc +++ b/google/cloud/logging/v2/internal/config_service_v2_auth_decorator.cc @@ -393,6 +393,31 @@ StatusOr ConfigServiceV2Auth::CopyLogEntries( return child_->CopyLogEntries(context, options, request); } +StatusOr +ConfigServiceV2Auth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr ConfigServiceV2Auth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status ConfigServiceV2Auth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + future> ConfigServiceV2Auth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/logging/v2/internal/config_service_v2_auth_decorator.h b/google/cloud/logging/v2/internal/config_service_v2_auth_decorator.h index 9ac5b43a3289d..7a85cecc1b771 100644 --- a/google/cloud/logging/v2/internal/config_service_v2_auth_decorator.h +++ b/google/cloud/logging/v2/internal/config_service_v2_auth_decorator.h @@ -197,6 +197,18 @@ class ConfigServiceV2Auth : public ConfigServiceV2Stub { grpc::ClientContext& context, Options options, google::logging::v2::CopyLogEntriesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/logging/v2/internal/config_service_v2_connection_impl.cc b/google/cloud/logging/v2/internal/config_service_v2_connection_impl.cc index 38357c59ffd6d..83942fca9b99a 100644 --- a/google/cloud/logging/v2/internal/config_service_v2_connection_impl.cc +++ b/google/cloud/logging/v2/internal/config_service_v2_connection_impl.cc @@ -964,6 +964,66 @@ ConfigServiceV2ConnectionImpl::CopyLogEntries( polling_policy(*current), __func__); } +StreamRange +ConfigServiceV2ConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ConfigServiceV2ConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ConfigServiceV2ConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace logging_v2_internal } // namespace cloud diff --git a/google/cloud/logging/v2/internal/config_service_v2_connection_impl.h b/google/cloud/logging/v2/internal/config_service_v2_connection_impl.h index 6cd907d960418..cb37fa6f2df49 100644 --- a/google/cloud/logging/v2/internal/config_service_v2_connection_impl.h +++ b/google/cloud/logging/v2/internal/config_service_v2_connection_impl.h @@ -183,6 +183,15 @@ class ConfigServiceV2ConnectionImpl future> CopyLogEntries( google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/logging/v2/internal/config_service_v2_logging_decorator.cc b/google/cloud/logging/v2/internal/config_service_v2_logging_decorator.cc index cc7ba78c0170d..9ba22e8c2e832 100644 --- a/google/cloud/logging/v2/internal/config_service_v2_logging_decorator.cc +++ b/google/cloud/logging/v2/internal/config_service_v2_logging_decorator.cc @@ -489,6 +489,40 @@ StatusOr ConfigServiceV2Logging::CopyLogEntries( context, options, request, __func__, tracing_options_); } +StatusOr +ConfigServiceV2Logging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ConfigServiceV2Logging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ConfigServiceV2Logging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> ConfigServiceV2Logging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/logging/v2/internal/config_service_v2_logging_decorator.h b/google/cloud/logging/v2/internal/config_service_v2_logging_decorator.h index 40065ec3a61fc..fa97296a8b1f7 100644 --- a/google/cloud/logging/v2/internal/config_service_v2_logging_decorator.h +++ b/google/cloud/logging/v2/internal/config_service_v2_logging_decorator.h @@ -197,6 +197,18 @@ class ConfigServiceV2Logging : public ConfigServiceV2Stub { grpc::ClientContext& context, Options options, google::logging::v2::CopyLogEntriesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/logging/v2/internal/config_service_v2_metadata_decorator.cc b/google/cloud/logging/v2/internal/config_service_v2_metadata_decorator.cc index 6bd0b92f94d79..d66580a221538 100644 --- a/google/cloud/logging/v2/internal/config_service_v2_metadata_decorator.cc +++ b/google/cloud/logging/v2/internal/config_service_v2_metadata_decorator.cc @@ -374,6 +374,31 @@ ConfigServiceV2Metadata::CopyLogEntries( return child_->CopyLogEntries(context, options, request); } +StatusOr +ConfigServiceV2Metadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr ConfigServiceV2Metadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status ConfigServiceV2Metadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + future> ConfigServiceV2Metadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/logging/v2/internal/config_service_v2_metadata_decorator.h b/google/cloud/logging/v2/internal/config_service_v2_metadata_decorator.h index 8f5975e3b5bae..c059e753f9542 100644 --- a/google/cloud/logging/v2/internal/config_service_v2_metadata_decorator.h +++ b/google/cloud/logging/v2/internal/config_service_v2_metadata_decorator.h @@ -198,6 +198,18 @@ class ConfigServiceV2Metadata : public ConfigServiceV2Stub { grpc::ClientContext& context, Options options, google::logging::v2::CopyLogEntriesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/logging/v2/internal/config_service_v2_stub.cc b/google/cloud/logging/v2/internal/config_service_v2_stub.cc index ebb8422b20db7..79cd43342f2cf 100644 --- a/google/cloud/logging/v2/internal/config_service_v2_stub.cc +++ b/google/cloud/logging/v2/internal/config_service_v2_stub.cc @@ -484,6 +484,41 @@ DefaultConfigServiceV2Stub::CopyLogEntries( return response; } +StatusOr +DefaultConfigServiceV2Stub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultConfigServiceV2Stub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultConfigServiceV2Stub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + future> DefaultConfigServiceV2Stub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/logging/v2/internal/config_service_v2_stub.h b/google/cloud/logging/v2/internal/config_service_v2_stub.h index 7b4cfa3e3eec2..68d22ad234195 100644 --- a/google/cloud/logging/v2/internal/config_service_v2_stub.h +++ b/google/cloud/logging/v2/internal/config_service_v2_stub.h @@ -198,6 +198,18 @@ class ConfigServiceV2Stub { grpc::ClientContext& context, Options options, google::logging::v2::CopyLogEntriesRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -216,9 +228,13 @@ class DefaultConfigServiceV2Stub : public ConfigServiceV2Stub { DefaultConfigServiceV2Stub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr ListBuckets( grpc::ClientContext& context, Options const& options, @@ -378,6 +394,18 @@ class DefaultConfigServiceV2Stub : public ConfigServiceV2Stub { grpc::ClientContext& context, Options options, google::logging::v2::CopyLogEntriesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -393,6 +421,8 @@ class DefaultConfigServiceV2Stub : public ConfigServiceV2Stub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/logging/v2/internal/config_service_v2_stub_factory.cc b/google/cloud/logging/v2/internal/config_service_v2_stub_factory.cc index b3b50272ea331..c94664e925f03 100644 --- a/google/cloud/logging/v2/internal/config_service_v2_stub_factory.cc +++ b/google/cloud/logging/v2/internal/config_service_v2_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 CreateDefaultConfigServiceV2Stub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::logging::v2::ConfigServiceV2::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/logging/v2/internal/config_service_v2_tracing_connection.cc b/google/cloud/logging/v2/internal/config_service_v2_tracing_connection.cc index 9aae8ad6c1701..298d5c120bce2 100644 --- a/google/cloud/logging/v2/internal/config_service_v2_tracing_connection.cc +++ b/google/cloud/logging/v2/internal/config_service_v2_tracing_connection.cc @@ -420,6 +420,34 @@ ConfigServiceV2TracingConnection::CopyLogEntries( return internal::EndSpan(std::move(span), child_->CopyLogEntries(operation)); } +StreamRange +ConfigServiceV2TracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "logging_v2::ConfigServiceV2Connection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ConfigServiceV2TracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("logging_v2::ConfigServiceV2Connection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status ConfigServiceV2TracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "logging_v2::ConfigServiceV2Connection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/logging/v2/internal/config_service_v2_tracing_connection.h b/google/cloud/logging/v2/internal/config_service_v2_tracing_connection.h index 29290cfbffb54..c672bdfa5bf8e 100644 --- a/google/cloud/logging/v2/internal/config_service_v2_tracing_connection.h +++ b/google/cloud/logging/v2/internal/config_service_v2_tracing_connection.h @@ -171,6 +171,15 @@ class ConfigServiceV2TracingConnection future> CopyLogEntries( google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/logging/v2/internal/config_service_v2_tracing_stub.cc b/google/cloud/logging/v2/internal/config_service_v2_tracing_stub.cc index 178e7461495a9..9fc459e9e7392 100644 --- a/google/cloud/logging/v2/internal/config_service_v2_tracing_stub.cc +++ b/google/cloud/logging/v2/internal/config_service_v2_tracing_stub.cc @@ -473,6 +473,41 @@ ConfigServiceV2TracingStub::CopyLogEntries( child_->CopyLogEntries(context, options, request)); } +StatusOr +ConfigServiceV2TracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.logging.v2.ConfigServiceV2", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +ConfigServiceV2TracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.logging.v2.ConfigServiceV2", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status ConfigServiceV2TracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.logging.v2.ConfigServiceV2", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + future> ConfigServiceV2TracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/logging/v2/internal/config_service_v2_tracing_stub.h b/google/cloud/logging/v2/internal/config_service_v2_tracing_stub.h index a6ea030a2889b..6bc90c54f9c39 100644 --- a/google/cloud/logging/v2/internal/config_service_v2_tracing_stub.h +++ b/google/cloud/logging/v2/internal/config_service_v2_tracing_stub.h @@ -197,6 +197,18 @@ class ConfigServiceV2TracingStub : public ConfigServiceV2Stub { grpc::ClientContext& context, Options options, google::logging::v2::CopyLogEntriesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/logging/v2/internal/logging_service_v2_auth_decorator.cc b/google/cloud/logging/v2/internal/logging_service_v2_auth_decorator.cc index 0e34e39bd6f07..abbc49fe4ddaa 100644 --- a/google/cloud/logging/v2/internal/logging_service_v2_auth_decorator.cc +++ b/google/cloud/logging/v2/internal/logging_service_v2_auth_decorator.cc @@ -95,6 +95,31 @@ LoggingServiceV2Auth::AsyncTailLogEntries( std::move(context), auth_, StreamAuth::StreamFactory(std::move(call))); } +StatusOr +LoggingServiceV2Auth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr LoggingServiceV2Auth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status LoggingServiceV2Auth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + future> LoggingServiceV2Auth::AsyncWriteLogEntries( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/logging/v2/internal/logging_service_v2_auth_decorator.h b/google/cloud/logging/v2/internal/logging_service_v2_auth_decorator.h index 5bf4fc8fb3592..c1488f0497b3b 100644 --- a/google/cloud/logging/v2/internal/logging_service_v2_auth_decorator.h +++ b/google/cloud/logging/v2/internal/logging_service_v2_auth_decorator.h @@ -68,6 +68,18 @@ class LoggingServiceV2Auth : public LoggingServiceV2Stub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncWriteLogEntries( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/logging/v2/internal/logging_service_v2_connection_impl.cc b/google/cloud/logging/v2/internal/logging_service_v2_connection_impl.cc index 267431cc53318..7cec802c3419c 100644 --- a/google/cloud/logging/v2/internal/logging_service_v2_connection_impl.cc +++ b/google/cloud/logging/v2/internal/logging_service_v2_connection_impl.cc @@ -196,6 +196,66 @@ LoggingServiceV2ConnectionImpl::AsyncTailLogEntries() { internal::SaveCurrentOptions()); } +StreamRange +LoggingServiceV2ConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +LoggingServiceV2ConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status LoggingServiceV2ConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + future> LoggingServiceV2ConnectionImpl::AsyncWriteLogEntries( google::logging::v2::WriteLogEntriesRequest const& request) { diff --git a/google/cloud/logging/v2/internal/logging_service_v2_connection_impl.h b/google/cloud/logging/v2/internal/logging_service_v2_connection_impl.h index d2628abdb9d82..41c60371cc3cb 100644 --- a/google/cloud/logging/v2/internal/logging_service_v2_connection_impl.h +++ b/google/cloud/logging/v2/internal/logging_service_v2_connection_impl.h @@ -72,6 +72,15 @@ class LoggingServiceV2ConnectionImpl google::logging::v2::TailLogEntriesResponse>> AsyncTailLogEntries() override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncWriteLogEntries( google::logging::v2::WriteLogEntriesRequest const& request) override; diff --git a/google/cloud/logging/v2/internal/logging_service_v2_logging_decorator.cc b/google/cloud/logging/v2/internal/logging_service_v2_logging_decorator.cc index 1a15167cfb072..1f5cc12be4e5d 100644 --- a/google/cloud/logging/v2/internal/logging_service_v2_logging_decorator.cc +++ b/google/cloud/logging/v2/internal/logging_service_v2_logging_decorator.cc @@ -123,6 +123,40 @@ LoggingServiceV2Logging::AsyncTailLogEntries( return stream; } +StatusOr +LoggingServiceV2Logging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr LoggingServiceV2Logging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status LoggingServiceV2Logging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> LoggingServiceV2Logging::AsyncWriteLogEntries( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/logging/v2/internal/logging_service_v2_logging_decorator.h b/google/cloud/logging/v2/internal/logging_service_v2_logging_decorator.h index a7b5eb6080c57..c529e5c02c145 100644 --- a/google/cloud/logging/v2/internal/logging_service_v2_logging_decorator.h +++ b/google/cloud/logging/v2/internal/logging_service_v2_logging_decorator.h @@ -68,6 +68,18 @@ class LoggingServiceV2Logging : public LoggingServiceV2Stub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncWriteLogEntries( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/logging/v2/internal/logging_service_v2_metadata_decorator.cc b/google/cloud/logging/v2/internal/logging_service_v2_metadata_decorator.cc index 7fe558b20f497..9ed90374b7e04 100644 --- a/google/cloud/logging/v2/internal/logging_service_v2_metadata_decorator.cc +++ b/google/cloud/logging/v2/internal/logging_service_v2_metadata_decorator.cc @@ -99,6 +99,31 @@ LoggingServiceV2Metadata::AsyncTailLogEntries( std::move(options)); } +StatusOr +LoggingServiceV2Metadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr LoggingServiceV2Metadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status LoggingServiceV2Metadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + future> LoggingServiceV2Metadata::AsyncWriteLogEntries( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/logging/v2/internal/logging_service_v2_metadata_decorator.h b/google/cloud/logging/v2/internal/logging_service_v2_metadata_decorator.h index 4a091e0ad5e12..2de1d3a3f1f6d 100644 --- a/google/cloud/logging/v2/internal/logging_service_v2_metadata_decorator.h +++ b/google/cloud/logging/v2/internal/logging_service_v2_metadata_decorator.h @@ -69,6 +69,18 @@ class LoggingServiceV2Metadata : public LoggingServiceV2Stub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncWriteLogEntries( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/logging/v2/internal/logging_service_v2_stub.cc b/google/cloud/logging/v2/internal/logging_service_v2_stub.cc index d4e32bc50a89a..7ea868867b99b 100644 --- a/google/cloud/logging/v2/internal/logging_service_v2_stub.cc +++ b/google/cloud/logging/v2/internal/logging_service_v2_stub.cc @@ -108,6 +108,41 @@ DefaultLoggingServiceV2Stub::AsyncTailLogEntries( }); } +StatusOr +DefaultLoggingServiceV2Stub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultLoggingServiceV2Stub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultLoggingServiceV2Stub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + future> DefaultLoggingServiceV2Stub::AsyncWriteLogEntries( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/logging/v2/internal/logging_service_v2_stub.h b/google/cloud/logging/v2/internal/logging_service_v2_stub.h index c75d926be666e..aeed66150c347 100644 --- a/google/cloud/logging/v2/internal/logging_service_v2_stub.h +++ b/google/cloud/logging/v2/internal/logging_service_v2_stub.h @@ -26,6 +26,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -69,6 +70,18 @@ class LoggingServiceV2Stub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncWriteLogEntries( google::cloud::CompletionQueue& cq, @@ -81,8 +94,11 @@ class DefaultLoggingServiceV2Stub : public LoggingServiceV2Stub { public: explicit DefaultLoggingServiceV2Stub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} Status DeleteLog( grpc::ClientContext& context, Options const& options, @@ -114,6 +130,18 @@ class DefaultLoggingServiceV2Stub : public LoggingServiceV2Stub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncWriteLogEntries( google::cloud::CompletionQueue& cq, @@ -124,6 +152,8 @@ class DefaultLoggingServiceV2Stub : public LoggingServiceV2Stub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/logging/v2/internal/logging_service_v2_stub_factory.cc b/google/cloud/logging/v2/internal/logging_service_v2_stub_factory.cc index 5fe6093267ecf..43364800dfddd 100644 --- a/google/cloud/logging/v2/internal/logging_service_v2_stub_factory.cc +++ b/google/cloud/logging/v2/internal/logging_service_v2_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 CreateDefaultLoggingServiceV2Stub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::logging::v2::LoggingServiceV2::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_operations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/logging/v2/internal/logging_service_v2_tracing_connection.cc b/google/cloud/logging/v2/internal/logging_service_v2_tracing_connection.cc index 98f730a55a6de..2ac32c950c02c 100644 --- a/google/cloud/logging/v2/internal/logging_service_v2_tracing_connection.cc +++ b/google/cloud/logging/v2/internal/logging_service_v2_tracing_connection.cc @@ -90,6 +90,34 @@ LoggingServiceV2TracingConnection::AsyncTailLogEntries() { return child_->AsyncTailLogEntries(); } +StreamRange +LoggingServiceV2TracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "logging_v2::LoggingServiceV2Connection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +LoggingServiceV2TracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "logging_v2::LoggingServiceV2Connection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status LoggingServiceV2TracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "logging_v2::LoggingServiceV2Connection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + future> LoggingServiceV2TracingConnection::AsyncWriteLogEntries( google::logging::v2::WriteLogEntriesRequest const& request) { diff --git a/google/cloud/logging/v2/internal/logging_service_v2_tracing_connection.h b/google/cloud/logging/v2/internal/logging_service_v2_tracing_connection.h index d09b63d52cadb..158d11145d710 100644 --- a/google/cloud/logging/v2/internal/logging_service_v2_tracing_connection.h +++ b/google/cloud/logging/v2/internal/logging_service_v2_tracing_connection.h @@ -62,6 +62,15 @@ class LoggingServiceV2TracingConnection google::logging::v2::TailLogEntriesResponse>> AsyncTailLogEntries() override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncWriteLogEntries( google::logging::v2::WriteLogEntriesRequest const& request) override; diff --git a/google/cloud/logging/v2/internal/logging_service_v2_tracing_stub.cc b/google/cloud/logging/v2/internal/logging_service_v2_tracing_stub.cc index 9dcc76ccf4c2c..2d1dbc5fa74a7 100644 --- a/google/cloud/logging/v2/internal/logging_service_v2_tracing_stub.cc +++ b/google/cloud/logging/v2/internal/logging_service_v2_tracing_stub.cc @@ -111,6 +111,41 @@ LoggingServiceV2TracingStub::AsyncTailLogEntries( std::move(context), std::move(stream), std::move(span)); } +StatusOr +LoggingServiceV2TracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.logging.v2.LoggingServiceV2", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +LoggingServiceV2TracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.logging.v2.LoggingServiceV2", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status LoggingServiceV2TracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.logging.v2.LoggingServiceV2", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + future> LoggingServiceV2TracingStub::AsyncWriteLogEntries( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/logging/v2/internal/logging_service_v2_tracing_stub.h b/google/cloud/logging/v2/internal/logging_service_v2_tracing_stub.h index 56a2bdc573703..a78f4509ccf2e 100644 --- a/google/cloud/logging/v2/internal/logging_service_v2_tracing_stub.h +++ b/google/cloud/logging/v2/internal/logging_service_v2_tracing_stub.h @@ -69,6 +69,18 @@ class LoggingServiceV2TracingStub : public LoggingServiceV2Stub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncWriteLogEntries( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/logging/v2/internal/metrics_service_v2_auth_decorator.cc b/google/cloud/logging/v2/internal/metrics_service_v2_auth_decorator.cc index 83cb7dedc0f4d..a2285a44ba552 100644 --- a/google/cloud/logging/v2/internal/metrics_service_v2_auth_decorator.cc +++ b/google/cloud/logging/v2/internal/metrics_service_v2_auth_decorator.cc @@ -72,6 +72,31 @@ Status MetricsServiceV2Auth::DeleteLogMetric( return child_->DeleteLogMetric(context, options, request); } +StatusOr +MetricsServiceV2Auth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr MetricsServiceV2Auth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status MetricsServiceV2Auth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace logging_v2_internal } // namespace cloud diff --git a/google/cloud/logging/v2/internal/metrics_service_v2_auth_decorator.h b/google/cloud/logging/v2/internal/metrics_service_v2_auth_decorator.h index cc64f9d70d1ba..c0344058c7f7c 100644 --- a/google/cloud/logging/v2/internal/metrics_service_v2_auth_decorator.h +++ b/google/cloud/logging/v2/internal/metrics_service_v2_auth_decorator.h @@ -58,6 +58,18 @@ class MetricsServiceV2Auth : public MetricsServiceV2Stub { grpc::ClientContext& context, Options const& options, google::logging::v2::DeleteLogMetricRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/logging/v2/internal/metrics_service_v2_connection_impl.cc b/google/cloud/logging/v2/internal/metrics_service_v2_connection_impl.cc index 004d8a6c39b81..cc5f45af7bb92 100644 --- a/google/cloud/logging/v2/internal/metrics_service_v2_connection_impl.cc +++ b/google/cloud/logging/v2/internal/metrics_service_v2_connection_impl.cc @@ -147,6 +147,66 @@ Status MetricsServiceV2ConnectionImpl::DeleteLogMetric( *current, request, __func__); } +StreamRange +MetricsServiceV2ConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +MetricsServiceV2ConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status MetricsServiceV2ConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace logging_v2_internal } // namespace cloud diff --git a/google/cloud/logging/v2/internal/metrics_service_v2_connection_impl.h b/google/cloud/logging/v2/internal/metrics_service_v2_connection_impl.h index 6d610df843c14..1a4414c5344d4 100644 --- a/google/cloud/logging/v2/internal/metrics_service_v2_connection_impl.h +++ b/google/cloud/logging/v2/internal/metrics_service_v2_connection_impl.h @@ -64,6 +64,15 @@ class MetricsServiceV2ConnectionImpl Status DeleteLogMetric( google::logging::v2::DeleteLogMetricRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/logging/v2/internal/metrics_service_v2_logging_decorator.cc b/google/cloud/logging/v2/internal/metrics_service_v2_logging_decorator.cc index 5691385f0c76f..fb01c578b44b3 100644 --- a/google/cloud/logging/v2/internal/metrics_service_v2_logging_decorator.cc +++ b/google/cloud/logging/v2/internal/metrics_service_v2_logging_decorator.cc @@ -93,6 +93,40 @@ Status MetricsServiceV2Logging::DeleteLogMetric( context, options, request, __func__, tracing_options_); } +StatusOr +MetricsServiceV2Logging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr MetricsServiceV2Logging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status MetricsServiceV2Logging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace logging_v2_internal } // namespace cloud diff --git a/google/cloud/logging/v2/internal/metrics_service_v2_logging_decorator.h b/google/cloud/logging/v2/internal/metrics_service_v2_logging_decorator.h index 73bc55230ec30..14662679fcad4 100644 --- a/google/cloud/logging/v2/internal/metrics_service_v2_logging_decorator.h +++ b/google/cloud/logging/v2/internal/metrics_service_v2_logging_decorator.h @@ -58,6 +58,18 @@ class MetricsServiceV2Logging : public MetricsServiceV2Stub { grpc::ClientContext& context, Options const& options, google::logging::v2::DeleteLogMetricRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/logging/v2/internal/metrics_service_v2_metadata_decorator.cc b/google/cloud/logging/v2/internal/metrics_service_v2_metadata_decorator.cc index ac1f89e592d61..c49a2082e5c1f 100644 --- a/google/cloud/logging/v2/internal/metrics_service_v2_metadata_decorator.cc +++ b/google/cloud/logging/v2/internal/metrics_service_v2_metadata_decorator.cc @@ -90,6 +90,31 @@ Status MetricsServiceV2Metadata::DeleteLogMetric( return child_->DeleteLogMetric(context, options, request); } +StatusOr +MetricsServiceV2Metadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr MetricsServiceV2Metadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status MetricsServiceV2Metadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + void MetricsServiceV2Metadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/logging/v2/internal/metrics_service_v2_metadata_decorator.h b/google/cloud/logging/v2/internal/metrics_service_v2_metadata_decorator.h index 398621bb5b44e..7e6f87c7622ac 100644 --- a/google/cloud/logging/v2/internal/metrics_service_v2_metadata_decorator.h +++ b/google/cloud/logging/v2/internal/metrics_service_v2_metadata_decorator.h @@ -59,6 +59,18 @@ class MetricsServiceV2Metadata : public MetricsServiceV2Stub { grpc::ClientContext& context, Options const& options, google::logging::v2::DeleteLogMetricRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/logging/v2/internal/metrics_service_v2_stub.cc b/google/cloud/logging/v2/internal/metrics_service_v2_stub.cc index 447fb2057cb09..1d60a7f5e4685 100644 --- a/google/cloud/logging/v2/internal/metrics_service_v2_stub.cc +++ b/google/cloud/logging/v2/internal/metrics_service_v2_stub.cc @@ -89,6 +89,41 @@ Status DefaultMetricsServiceV2Stub::DeleteLogMetric( return google::cloud::Status(); } +StatusOr +DefaultMetricsServiceV2Stub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultMetricsServiceV2Stub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultMetricsServiceV2Stub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace logging_v2_internal } // namespace cloud diff --git a/google/cloud/logging/v2/internal/metrics_service_v2_stub.h b/google/cloud/logging/v2/internal/metrics_service_v2_stub.h index 3a4e8a91bf7b8..3f7f8db3688b1 100644 --- a/google/cloud/logging/v2/internal/metrics_service_v2_stub.h +++ b/google/cloud/logging/v2/internal/metrics_service_v2_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -54,14 +55,29 @@ class MetricsServiceV2Stub { virtual Status DeleteLogMetric( grpc::ClientContext& context, Options const& options, google::logging::v2::DeleteLogMetricRequest const& request) = 0; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultMetricsServiceV2Stub : public MetricsServiceV2Stub { public: explicit DefaultMetricsServiceV2Stub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr ListLogMetrics( grpc::ClientContext& context, Options const& options, @@ -83,9 +99,23 @@ class DefaultMetricsServiceV2Stub : public MetricsServiceV2Stub { grpc::ClientContext& context, Options const& options, google::logging::v2::DeleteLogMetricRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/logging/v2/internal/metrics_service_v2_stub_factory.cc b/google/cloud/logging/v2/internal/metrics_service_v2_stub_factory.cc index 69a8dac1340a5..9c366cae1ec71 100644 --- a/google/cloud/logging/v2/internal/metrics_service_v2_stub_factory.cc +++ b/google/cloud/logging/v2/internal/metrics_service_v2_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 CreateDefaultMetricsServiceV2Stub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::logging::v2::MetricsServiceV2::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_operations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/logging/v2/internal/metrics_service_v2_tracing_connection.cc b/google/cloud/logging/v2/internal/metrics_service_v2_tracing_connection.cc index e2004125053ff..824108069b52c 100644 --- a/google/cloud/logging/v2/internal/metrics_service_v2_tracing_connection.cc +++ b/google/cloud/logging/v2/internal/metrics_service_v2_tracing_connection.cc @@ -79,6 +79,34 @@ Status MetricsServiceV2TracingConnection::DeleteLogMetric( return internal::EndSpan(*span, child_->DeleteLogMetric(request)); } +StreamRange +MetricsServiceV2TracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "logging_v2::MetricsServiceV2Connection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +MetricsServiceV2TracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "logging_v2::MetricsServiceV2Connection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status MetricsServiceV2TracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "logging_v2::MetricsServiceV2Connection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/logging/v2/internal/metrics_service_v2_tracing_connection.h b/google/cloud/logging/v2/internal/metrics_service_v2_tracing_connection.h index db1143673843d..393bd76128f6a 100644 --- a/google/cloud/logging/v2/internal/metrics_service_v2_tracing_connection.h +++ b/google/cloud/logging/v2/internal/metrics_service_v2_tracing_connection.h @@ -55,6 +55,15 @@ class MetricsServiceV2TracingConnection Status DeleteLogMetric( google::logging::v2::DeleteLogMetricRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/logging/v2/internal/metrics_service_v2_tracing_stub.cc b/google/cloud/logging/v2/internal/metrics_service_v2_tracing_stub.cc index 74159e800d5e3..1210a27aefaf9 100644 --- a/google/cloud/logging/v2/internal/metrics_service_v2_tracing_stub.cc +++ b/google/cloud/logging/v2/internal/metrics_service_v2_tracing_stub.cc @@ -91,6 +91,41 @@ Status MetricsServiceV2TracingStub::DeleteLogMetric( child_->DeleteLogMetric(context, options, request)); } +StatusOr +MetricsServiceV2TracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.logging.v2.MetricsServiceV2", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +MetricsServiceV2TracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.logging.v2.MetricsServiceV2", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status MetricsServiceV2TracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.logging.v2.MetricsServiceV2", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeMetricsServiceV2TracingStub( diff --git a/google/cloud/logging/v2/internal/metrics_service_v2_tracing_stub.h b/google/cloud/logging/v2/internal/metrics_service_v2_tracing_stub.h index 3b19f19e8b572..9cc346d9a8f3f 100644 --- a/google/cloud/logging/v2/internal/metrics_service_v2_tracing_stub.h +++ b/google/cloud/logging/v2/internal/metrics_service_v2_tracing_stub.h @@ -59,6 +59,18 @@ class MetricsServiceV2TracingStub : public MetricsServiceV2Stub { grpc::ClientContext& context, Options const& options, google::logging::v2::DeleteLogMetricRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/logging/v2/logging_service_v2_client.cc b/google/cloud/logging/v2/logging_service_v2_client.cc index 2fb7dd1f05525..45d1f2e2b902f 100644 --- a/google/cloud/logging/v2/logging_service_v2_client.cc +++ b/google/cloud/logging/v2/logging_service_v2_client.cc @@ -117,6 +117,52 @@ LoggingServiceV2Client::AsyncTailLogEntries(Options opts) { return connection_->AsyncTailLogEntries(); } +StreamRange +LoggingServiceV2Client::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +LoggingServiceV2Client::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr LoggingServiceV2Client::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr LoggingServiceV2Client::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status LoggingServiceV2Client::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status LoggingServiceV2Client::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + future> LoggingServiceV2Client::AsyncWriteLogEntries( std::string const& log_name, google::api::MonitoredResource const& resource, diff --git a/google/cloud/logging/v2/logging_service_v2_client.h b/google/cloud/logging/v2/logging_service_v2_client.h index 505534539c7bf..194deacbc1ef7 100644 --- a/google/cloud/logging/v2/logging_service_v2_client.h +++ b/google/cloud/logging/v2/logging_service_v2_client.h @@ -515,6 +515,231 @@ class LoggingServiceV2Client { google::logging::v2::TailLogEntriesResponse>> AsyncTailLogEntries(Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + // clang-format off /// /// Writes log entries to Logging. This API method is the diff --git a/google/cloud/logging/v2/logging_service_v2_connection.cc b/google/cloud/logging/v2/logging_service_v2_connection.cc index cdfe606ba240f..bbe8781c93643 100644 --- a/google/cloud/logging/v2/logging_service_v2_connection.cc +++ b/google/cloud/logging/v2/logging_service_v2_connection.cc @@ -83,6 +83,25 @@ LoggingServiceV2Connection::AsyncTailLogEntries() { Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +LoggingServiceV2Connection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +LoggingServiceV2Connection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status LoggingServiceV2Connection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + future> LoggingServiceV2Connection::AsyncWriteLogEntries( google::logging::v2::WriteLogEntriesRequest const&) { diff --git a/google/cloud/logging/v2/logging_service_v2_connection.h b/google/cloud/logging/v2/logging_service_v2_connection.h index 3204b4821f69e..c87e8f144f52d 100644 --- a/google/cloud/logging/v2/logging_service_v2_connection.h +++ b/google/cloud/logging/v2/logging_service_v2_connection.h @@ -208,6 +208,15 @@ class LoggingServiceV2Connection { google::logging::v2::TailLogEntriesResponse>> AsyncTailLogEntries(); + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); + virtual future> AsyncWriteLogEntries( google::logging::v2::WriteLogEntriesRequest const& request); diff --git a/google/cloud/logging/v2/logging_service_v2_connection_idempotency_policy.cc b/google/cloud/logging/v2/logging_service_v2_connection_idempotency_policy.cc index b7a2d24de2876..8eb926d49afd6 100644 --- a/google/cloud/logging/v2/logging_service_v2_connection_idempotency_policy.cc +++ b/google/cloud/logging/v2/logging_service_v2_connection_idempotency_policy.cc @@ -60,6 +60,21 @@ Idempotency LoggingServiceV2ConnectionIdempotencyPolicy::ListLogs( return Idempotency::kIdempotent; } +Idempotency LoggingServiceV2ConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency LoggingServiceV2ConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency LoggingServiceV2ConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultLoggingServiceV2ConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/logging/v2/logging_service_v2_connection_idempotency_policy.h b/google/cloud/logging/v2/logging_service_v2_connection_idempotency_policy.h index c3fbb16352a28..b6ca281f9cb0f 100644 --- a/google/cloud/logging/v2/logging_service_v2_connection_idempotency_policy.h +++ b/google/cloud/logging/v2/logging_service_v2_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 LoggingServiceV2ConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListLogs( google::logging::v2::ListLogsRequest request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/logging/v2/metrics_service_v2_client.cc b/google/cloud/logging/v2/metrics_service_v2_client.cc index 6261fef7e1d20..b123df8751c13 100644 --- a/google/cloud/logging/v2/metrics_service_v2_client.cc +++ b/google/cloud/logging/v2/metrics_service_v2_client.cc @@ -112,6 +112,52 @@ Status MetricsServiceV2Client::DeleteLogMetric( return connection_->DeleteLogMetric(request); } +StreamRange +MetricsServiceV2Client::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +MetricsServiceV2Client::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr MetricsServiceV2Client::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr MetricsServiceV2Client::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status MetricsServiceV2Client::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status MetricsServiceV2Client::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace logging_v2 } // namespace cloud diff --git a/google/cloud/logging/v2/metrics_service_v2_client.h b/google/cloud/logging/v2/metrics_service_v2_client.h index c468e53f32806..495fac2dfad64 100644 --- a/google/cloud/logging/v2/metrics_service_v2_client.h +++ b/google/cloud/logging/v2/metrics_service_v2_client.h @@ -398,6 +398,231 @@ class MetricsServiceV2Client { google::logging::v2::DeleteLogMetricRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/logging/v2/metrics_service_v2_connection.cc b/google/cloud/logging/v2/metrics_service_v2_connection.cc index 1ce32a28bec70..d814b2586a6e9 100644 --- a/google/cloud/logging/v2/metrics_service_v2_connection.cc +++ b/google/cloud/logging/v2/metrics_service_v2_connection.cc @@ -69,6 +69,25 @@ Status MetricsServiceV2Connection::DeleteLogMetric( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +MetricsServiceV2Connection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +MetricsServiceV2Connection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status MetricsServiceV2Connection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeMetricsServiceV2Connection( Options options) { internal::CheckExpectedOptions ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/logging/v2/metrics_service_v2_connection_idempotency_policy.cc b/google/cloud/logging/v2/metrics_service_v2_connection_idempotency_policy.cc index 087b42d64fa7b..9cc48b6b8e72e 100644 --- a/google/cloud/logging/v2/metrics_service_v2_connection_idempotency_policy.cc +++ b/google/cloud/logging/v2/metrics_service_v2_connection_idempotency_policy.cc @@ -59,6 +59,21 @@ Idempotency MetricsServiceV2ConnectionIdempotencyPolicy::DeleteLogMetric( return Idempotency::kNonIdempotent; } +Idempotency MetricsServiceV2ConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency MetricsServiceV2ConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency MetricsServiceV2ConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultMetricsServiceV2ConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/logging/v2/metrics_service_v2_connection_idempotency_policy.h b/google/cloud/logging/v2/metrics_service_v2_connection_idempotency_policy.h index 6ed068baa9001..fbbc39fcfcd2c 100644 --- a/google/cloud/logging/v2/metrics_service_v2_connection_idempotency_policy.h +++ b/google/cloud/logging/v2/metrics_service_v2_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 MetricsServiceV2ConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteLogMetric( google::logging::v2::DeleteLogMetricRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/logging/v2/mocks/mock_config_service_v2_connection.h b/google/cloud/logging/v2/mocks/mock_config_service_v2_connection.h index 2d290bd8e6ee1..729ab151d1d54 100644 --- a/google/cloud/logging/v2/mocks/mock_config_service_v2_connection.h +++ b/google/cloud/logging/v2/mocks/mock_config_service_v2_connection.h @@ -325,6 +325,17 @@ class MockConfigServiceV2Connection MOCK_METHOD(future>, CopyLogEntries, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/logging/v2/mocks/mock_logging_service_v2_connection.h b/google/cloud/logging/v2/mocks/mock_logging_service_v2_connection.h index deaa5873b1f7c..a171ed699dc19 100644 --- a/google/cloud/logging/v2/mocks/mock_logging_service_v2_connection.h +++ b/google/cloud/logging/v2/mocks/mock_logging_service_v2_connection.h @@ -73,6 +73,17 @@ class MockLoggingServiceV2Connection google::logging::v2::TailLogEntriesResponse>>), AsyncTailLogEntries, (), (override)); + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); + MOCK_METHOD(future>, AsyncWriteLogEntries, (google::logging::v2::WriteLogEntriesRequest const& request), diff --git a/google/cloud/logging/v2/mocks/mock_metrics_service_v2_connection.h b/google/cloud/logging/v2/mocks/mock_metrics_service_v2_connection.h index d1d78e13820d7..082973ef2186d 100644 --- a/google/cloud/logging/v2/mocks/mock_metrics_service_v2_connection.h +++ b/google/cloud/logging/v2/mocks/mock_metrics_service_v2_connection.h @@ -65,6 +65,17 @@ class MockMetricsServiceV2Connection MOCK_METHOD(Status, DeleteLogMetric, (google::logging::v2::DeleteLogMetricRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..4e257f3efddb3 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,56 @@ 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); +} + +StatusOr +ManagedKafkaAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr ManagedKafkaAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status ManagedKafkaAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status ManagedKafkaAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..212e9c1f76ea8 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..b0141d2650524 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,127 @@ 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__); +} + +StreamRange +ManagedKafkaConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ManagedKafkaConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ManagedKafkaConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ManagedKafkaConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..1171a654cad7f 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..9e653e3be44f3 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,74 @@ 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_); +} + +StatusOr +ManagedKafkaLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ManagedKafkaLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ManagedKafkaLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ManagedKafkaLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..101354382e88b 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..d53b20d910cd3 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,56 @@ 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); +} + +StatusOr +ManagedKafkaMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr ManagedKafkaMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status ManagedKafkaMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status ManagedKafkaMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..311f5d4c11d1f 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..3312277891dbc 100644 --- a/google/cloud/managedkafka/v1/internal/managed_kafka_stub.cc +++ b/google/cloud/managedkafka/v1/internal/managed_kafka_stub.cc @@ -253,6 +253,75 @@ 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; +} + +StatusOr +DefaultManagedKafkaStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultManagedKafkaStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultManagedKafkaStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultManagedKafkaStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..324e00b54db88 100644 --- a/google/cloud/managedkafka/v1/internal/managed_kafka_stub.h +++ b/google/cloud/managedkafka/v1/internal/managed_kafka_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 @@ -121,6 +122,31 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -140,9 +166,16 @@ class DefaultManagedKafkaStub : public ManagedKafkaStub { std::unique_ptr< google::cloud::managedkafka::v1::ManagedKafka::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListClusters( grpc::ClientContext& context, Options const& options, @@ -234,6 +267,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -249,6 +306,10 @@ class DefaultManagedKafkaStub : public ManagedKafkaStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..c4918776b3295 100644 --- a/google/cloud/managedkafka/v1/internal/managed_kafka_stub_factory.cc +++ b/google/cloud/managedkafka/v1/internal/managed_kafka_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,14 @@ std::shared_ptr CreateDefaultManagedKafkaStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::managedkafka::v1::ManagedKafka::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..67b222d3b266c 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,62 @@ 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)); +} + +StreamRange +ManagedKafkaTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "managedkafka_v1::ManagedKafkaConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ManagedKafkaTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "managedkafka_v1::ManagedKafkaConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status ManagedKafkaTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "managedkafka_v1::ManagedKafkaConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status ManagedKafkaTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "managedkafka_v1::ManagedKafkaConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..f4427cfb11eb4 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..fbfd2fa7a5a55 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,75 @@ 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)); +} + +StatusOr +ManagedKafkaTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.managedkafka.v1.ManagedKafka", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr ManagedKafkaTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.managedkafka.v1.ManagedKafka", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status ManagedKafkaTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.managedkafka.v1.ManagedKafka", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status ManagedKafkaTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.managedkafka.v1.ManagedKafka", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..09e28a26f080b 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..9faf8e47fe7fe 100644 --- a/google/cloud/managedkafka/v1/managed_kafka_client.cc +++ b/google/cloud/managedkafka/v1/managed_kafka_client.cc @@ -346,6 +346,76 @@ 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); +} + +StreamRange ManagedKafkaClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange ManagedKafkaClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr ManagedKafkaClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr ManagedKafkaClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status ManagedKafkaClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status ManagedKafkaClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status ManagedKafkaClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status ManagedKafkaClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..07d55589b2d62 100644 --- a/google/cloud/managedkafka/v1/managed_kafka_client.h +++ b/google/cloud/managedkafka/v1/managed_kafka_client.h @@ -1137,6 +1137,356 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..6dcf25a75de0e 100644 --- a/google/cloud/managedkafka/v1/managed_kafka_connection.cc +++ b/google/cloud/managedkafka/v1/managed_kafka_connection.cc @@ -171,6 +171,42 @@ 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"); +} + +StreamRange +ManagedKafkaConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr ManagedKafkaConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ManagedKafkaConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ManagedKafkaConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeManagedKafkaConnection( Options options) { internal::CheckExpectedOptions ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..0c175ff6759bb 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,36 @@ 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; +} + +Idempotency ManagedKafkaConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ManagedKafkaConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ManagedKafkaConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency ManagedKafkaConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..cba69b1ef0e36 100644 --- a/google/cloud/managedkafka/v1/managed_kafka_connection_idempotency_policy.h +++ b/google/cloud/managedkafka/v1/managed_kafka_connection_idempotency_policy.h @@ -21,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -80,6 +82,24 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..bb68d27ef66b0 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,29 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..73b30f11c973d 100644 --- a/google/cloud/memcache/v1/cloud_memcache_client.cc +++ b/google/cloud/memcache/v1/cloud_memcache_client.cc @@ -341,6 +341,76 @@ 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); +} + +StreamRange CloudMemcacheClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange CloudMemcacheClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr CloudMemcacheClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr CloudMemcacheClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status CloudMemcacheClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status CloudMemcacheClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status CloudMemcacheClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status CloudMemcacheClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..89f4480d97422 100644 --- a/google/cloud/memcache/v1/cloud_memcache_client.h +++ b/google/cloud/memcache/v1/cloud_memcache_client.h @@ -973,6 +973,356 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..29d55f80d0ba0 100644 --- a/google/cloud/memcache/v1/cloud_memcache_connection.cc +++ b/google/cloud/memcache/v1/cloud_memcache_connection.cc @@ -188,6 +188,43 @@ 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"); +} + +StreamRange +CloudMemcacheConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr CloudMemcacheConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status CloudMemcacheConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status CloudMemcacheConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeCloudMemcacheConnection( Options options) { internal::CheckExpectedOptions> RescheduleMaintenance(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..b64c8f4617fdd 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,36 @@ 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; +} + +Idempotency CloudMemcacheConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency CloudMemcacheConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency CloudMemcacheConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency CloudMemcacheConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..e60afc8229530 100644 --- a/google/cloud/memcache/v1/cloud_memcache_connection_idempotency_policy.h +++ b/google/cloud/memcache/v1/cloud_memcache_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,24 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..527ea70dd58e2 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,56 @@ 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); +} + +StatusOr +CloudMemcacheAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr CloudMemcacheAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status CloudMemcacheAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status CloudMemcacheAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..a4b4c6422844f 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..6b9882f7d816c 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,127 @@ 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__); +} + +StreamRange +CloudMemcacheConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +CloudMemcacheConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status CloudMemcacheConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status CloudMemcacheConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..1f398abf38889 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..89c14660837fd 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,74 @@ 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_); +} + +StatusOr +CloudMemcacheLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr CloudMemcacheLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status CloudMemcacheLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status CloudMemcacheLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..b63518362e26c 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..0cc34713c2b88 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,56 @@ 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); +} + +StatusOr +CloudMemcacheMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr CloudMemcacheMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status CloudMemcacheMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status CloudMemcacheMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..38a0e3ac1b1ff 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..6069892c8869b 100644 --- a/google/cloud/memcache/v1/internal/cloud_memcache_stub.cc +++ b/google/cloud/memcache/v1/internal/cloud_memcache_stub.cc @@ -237,6 +237,75 @@ 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; +} + +StatusOr +DefaultCloudMemcacheStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultCloudMemcacheStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultCloudMemcacheStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultCloudMemcacheStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..cf5ae005eaef8 100644 --- a/google/cloud/memcache/v1/internal/cloud_memcache_stub.h +++ b/google/cloud/memcache/v1/internal/cloud_memcache_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 @@ -111,6 +112,31 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -129,9 +155,16 @@ class DefaultCloudMemcacheStub : public CloudMemcacheStub { DefaultCloudMemcacheStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListInstances( grpc::ClientContext& context, Options const& options, @@ -214,6 +247,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -229,6 +286,10 @@ class DefaultCloudMemcacheStub : public CloudMemcacheStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..95c5dbad8bde1 100644 --- a/google/cloud/memcache/v1/internal/cloud_memcache_stub_factory.cc +++ b/google/cloud/memcache/v1/internal/cloud_memcache_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,14 @@ std::shared_ptr CreateDefaultCloudMemcacheStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::memcache::v1::CloudMemcache::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..bd21eb7ef1b13 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,62 @@ 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)); +} + +StreamRange +CloudMemcacheTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "memcache_v1::CloudMemcacheConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +CloudMemcacheTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("memcache_v1::CloudMemcacheConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status CloudMemcacheTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "memcache_v1::CloudMemcacheConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status CloudMemcacheTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "memcache_v1::CloudMemcacheConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..a77734d587f09 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..7f01af79327b7 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,75 @@ 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)); +} + +StatusOr +CloudMemcacheTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.memcache.v1.CloudMemcache", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr CloudMemcacheTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.memcache.v1.CloudMemcache", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status CloudMemcacheTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.memcache.v1.CloudMemcache", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status CloudMemcacheTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.memcache.v1.CloudMemcache", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..02884eb8f59af 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..17e29ded9be66 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,29 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..b5df5d63bb2cc 100644 --- a/google/cloud/metastore/v1/dataproc_metastore_client.cc +++ b/google/cloud/metastore/v1/dataproc_metastore_client.cc @@ -588,6 +588,99 @@ 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); +} + +StreamRange +DataprocMetastoreClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +DataprocMetastoreClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr DataprocMetastoreClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr DataprocMetastoreClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status DataprocMetastoreClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status DataprocMetastoreClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status DataprocMetastoreClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status DataprocMetastoreClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..ec6282b4952a7 100644 --- a/google/cloud/metastore/v1/dataproc_metastore_client.h +++ b/google/cloud/metastore/v1/dataproc_metastore_client.h @@ -1781,6 +1781,458 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..274c0009b8a56 100644 --- a/google/cloud/metastore/v1/dataproc_metastore_connection.cc +++ b/google/cloud/metastore/v1/dataproc_metastore_connection.cc @@ -362,6 +362,60 @@ 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"); +} + +StreamRange +DataprocMetastoreConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +DataprocMetastoreConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DataprocMetastoreConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DataprocMetastoreConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDataprocMetastoreConnection( Options options) { internal::CheckExpectedOptions> 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..f42be742c5e82 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,52 @@ 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; +} + +Idempotency DataprocMetastoreConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DataprocMetastoreConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DataprocMetastoreConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency DataprocMetastoreConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..b4efe3e332a94 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,10 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include +#include #include namespace google { @@ -91,6 +94,33 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..7640aecc14bea 100644 --- a/google/cloud/metastore/v1/dataproc_metastore_federation_client.cc +++ b/google/cloud/metastore/v1/dataproc_metastore_federation_client.cc @@ -207,6 +207,103 @@ 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); +} + +StreamRange +DataprocMetastoreFederationClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +DataprocMetastoreFederationClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +DataprocMetastoreFederationClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +DataprocMetastoreFederationClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status DataprocMetastoreFederationClient::DeleteOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status DataprocMetastoreFederationClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status DataprocMetastoreFederationClient::CancelOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status DataprocMetastoreFederationClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..b6185f9ea311e 100644 --- a/google/cloud/metastore/v1/dataproc_metastore_federation_client.h +++ b/google/cloud/metastore/v1/dataproc_metastore_federation_client.h @@ -607,6 +607,458 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..eaa3fa0fd2e07 100644 --- a/google/cloud/metastore/v1/dataproc_metastore_federation_connection.cc +++ b/google/cloud/metastore/v1/dataproc_metastore_federation_connection.cc @@ -122,6 +122,62 @@ 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"); +} + +StreamRange +DataprocMetastoreFederationConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +DataprocMetastoreFederationConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DataprocMetastoreFederationConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DataprocMetastoreFederationConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDataprocMetastoreFederationConnection(Options options) { internal::CheckExpectedOptions> 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..5afa24ff5c313 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,60 @@ 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; +} + +Idempotency +DataprocMetastoreFederationConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency +DataprocMetastoreFederationConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +DataprocMetastoreFederationConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency +DataprocMetastoreFederationConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..434d64d90a4d3 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,10 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include +#include #include namespace google { @@ -52,6 +55,33 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..772731a108094 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,81 @@ 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); +} + +StatusOr +DataprocMetastoreAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr DataprocMetastoreAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status DataprocMetastoreAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status DataprocMetastoreAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..d7135ad88735e 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..8378b14fe3916 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,167 @@ 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__); +} + +StreamRange +DataprocMetastoreConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DataprocMetastoreConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DataprocMetastoreConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DataprocMetastoreConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..1f327a778fa5e 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..25b3d0d56a65b 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,83 @@ 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); +} + +StatusOr +DataprocMetastoreFederationAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +DataprocMetastoreFederationAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status DataprocMetastoreFederationAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status DataprocMetastoreFederationAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..f1503af5067bd 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..c623705e31930 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,171 @@ 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__); +} + +StreamRange +DataprocMetastoreFederationConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DataprocMetastoreFederationConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DataprocMetastoreFederationConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DataprocMetastoreFederationConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..ec3fe203131d3 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..c8cc96e8cdfed 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,112 @@ 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_); +} + +StatusOr +DataprocMetastoreFederationLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataprocMetastoreFederationLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DataprocMetastoreFederationLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DataprocMetastoreFederationLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..69d5defcd7109 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..f8820a4c6f03f 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,88 @@ 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); +} + +StatusOr +DataprocMetastoreFederationMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +DataprocMetastoreFederationMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status DataprocMetastoreFederationMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status DataprocMetastoreFederationMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..92f2612eb0fcf 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..39d4ff561b6c6 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,113 @@ 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; +} + +StatusOr +DefaultDataprocMetastoreFederationStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataprocMetastoreFederationStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultDataprocMetastoreFederationStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultDataprocMetastoreFederationStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..2deb95e08b7e0 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,9 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include +#include #include #include #include @@ -80,6 +82,44 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -100,9 +140,18 @@ class DefaultDataprocMetastoreFederationStub std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +199,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -166,6 +251,11 @@ class DefaultDataprocMetastoreFederationStub std::unique_ptr< google::cloud::metastore::v1::DataprocMetastoreFederation::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..6fd8d9a0d5bc3 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,10 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include +#include +#include #include #include @@ -46,9 +49,15 @@ CreateDefaultDataprocMetastoreFederationStub( auto service_grpc_stub = google::cloud::metastore::v1::DataprocMetastoreFederation::NewStub( channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..e75ddd7ff3e40 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,90 @@ 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)); +} + +StreamRange +DataprocMetastoreFederationTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "metastore_v1::DataprocMetastoreFederationConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DataprocMetastoreFederationTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "metastore_v1::DataprocMetastoreFederationConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status DataprocMetastoreFederationTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "metastore_v1::DataprocMetastoreFederationConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status DataprocMetastoreFederationTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "metastore_v1::DataprocMetastoreFederationConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..e12254d0ff9c8 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..762771da8360c 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,116 @@ 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)); +} + +StatusOr +DataprocMetastoreFederationTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.metastore.v1.DataprocMetastoreFederation", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +DataprocMetastoreFederationTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.metastore.v1.DataprocMetastoreFederation", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status DataprocMetastoreFederationTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.metastore.v1.DataprocMetastoreFederation", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status DataprocMetastoreFederationTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.metastore.v1.DataprocMetastoreFederation", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..986a10423809b 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..3dee1bd4433df 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,109 @@ 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_); +} + +StatusOr +DataprocMetastoreLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DataprocMetastoreLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DataprocMetastoreLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DataprocMetastoreLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..e4b3f8b67d3e8 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..ca74827d760b1 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,86 @@ 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); +} + +StatusOr +DataprocMetastoreMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +DataprocMetastoreMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status DataprocMetastoreMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status DataprocMetastoreMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..f3eb9576a037d 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..083e2a3769a6d 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_stub.cc +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_stub.cc @@ -471,6 +471,111 @@ 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; +} + +StatusOr +DefaultDataprocMetastoreStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataprocMetastoreStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultDataprocMetastoreStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultDataprocMetastoreStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..a816353c0008d 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_stub.h +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_stub.h @@ -24,7 +24,9 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include +#include #include #include #include @@ -201,6 +203,44 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -220,9 +260,18 @@ class DefaultDataprocMetastoreStub : public DataprocMetastoreStub { std::unique_ptr< google::cloud::metastore::v1::DataprocMetastore::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +446,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -413,6 +498,11 @@ class DefaultDataprocMetastoreStub : public DataprocMetastoreStub { std::unique_ptr< google::cloud::metastore::v1::DataprocMetastore::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..b19d1a67e7b04 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,10 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultDataprocMetastoreStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::metastore::v1::DataprocMetastore::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..497259ee3a3a4 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,89 @@ 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)); +} + +StreamRange +DataprocMetastoreTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "metastore_v1::DataprocMetastoreConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DataprocMetastoreTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "metastore_v1::DataprocMetastoreConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status DataprocMetastoreTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "metastore_v1::DataprocMetastoreConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status DataprocMetastoreTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "metastore_v1::DataprocMetastoreConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..546e51ca3e786 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..e0421e4023397 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,110 @@ 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)); +} + +StatusOr +DataprocMetastoreTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.metastore.v1.DataprocMetastore", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +DataprocMetastoreTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.metastore.v1.DataprocMetastore", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status DataprocMetastoreTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.metastore.v1.DataprocMetastore", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status DataprocMetastoreTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.metastore.v1.DataprocMetastore", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..3c6b2e2f6c2c2 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..d4ac8cd3ad884 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,42 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..e8fada3fd4614 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,42 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..137565f94659a 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,56 @@ 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); +} + +StatusOr +MigrationCenterAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr MigrationCenterAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status MigrationCenterAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status MigrationCenterAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..da65393253175 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..ee32ec48f0262 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,127 @@ 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__); +} + +StreamRange +MigrationCenterConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +MigrationCenterConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status MigrationCenterConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status MigrationCenterConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..b95a719b5b5a2 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..75ae1b230858d 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,74 @@ 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_); +} + +StatusOr +MigrationCenterLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr MigrationCenterLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status MigrationCenterLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status MigrationCenterLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..b51a77d24aa57 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..370a4ce90d543 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,57 @@ 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); +} + +StatusOr +MigrationCenterMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr MigrationCenterMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status MigrationCenterMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status MigrationCenterMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..34e1eeb088265 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..cd1e5cf5bab64 100644 --- a/google/cloud/migrationcenter/v1/internal/migration_center_stub.cc +++ b/google/cloud/migrationcenter/v1/internal/migration_center_stub.cc @@ -1078,6 +1078,76 @@ 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; +} + +StatusOr +DefaultMigrationCenterStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultMigrationCenterStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultMigrationCenterStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultMigrationCenterStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..8b129e8869673 100644 --- a/google/cloud/migrationcenter/v1/internal/migration_center_stub.h +++ b/google/cloud/migrationcenter/v1/internal/migration_center_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 @@ -462,6 +463,31 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -481,9 +507,16 @@ class DefaultMigrationCenterStub : public MigrationCenterStub { std::unique_ptr< google::cloud::migrationcenter::v1::MigrationCenter::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListAssets( grpc::ClientContext& context, Options const& options, @@ -895,6 +928,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -911,6 +968,10 @@ class DefaultMigrationCenterStub : public MigrationCenterStub { std::unique_ptr< google::cloud::migrationcenter::v1::MigrationCenter::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..a58f273cf077a 100644 --- a/google/cloud/migrationcenter/v1/internal/migration_center_stub_factory.cc +++ b/google/cloud/migrationcenter/v1/internal/migration_center_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,14 @@ std::shared_ptr CreateDefaultMigrationCenterStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::migrationcenter::v1::MigrationCenter::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..faae7dfc21e82 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,62 @@ 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)); +} + +StreamRange +MigrationCenterTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "migrationcenter_v1::MigrationCenterConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +MigrationCenterTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "migrationcenter_v1::MigrationCenterConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status MigrationCenterTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "migrationcenter_v1::MigrationCenterConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status MigrationCenterTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "migrationcenter_v1::MigrationCenterConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..38abdf782971d 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..26397676502a6 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,76 @@ 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)); +} + +StatusOr +MigrationCenterTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.migrationcenter.v1.MigrationCenter", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +MigrationCenterTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.migrationcenter.v1.MigrationCenter", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status MigrationCenterTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.migrationcenter.v1.MigrationCenter", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status MigrationCenterTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.migrationcenter.v1.MigrationCenter", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..21822ba25a5b7 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..d831e108877eb 100644 --- a/google/cloud/migrationcenter/v1/migration_center_client.cc +++ b/google/cloud/migrationcenter/v1/migration_center_client.cc @@ -1459,6 +1459,78 @@ 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); +} + +StreamRange +MigrationCenterClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +MigrationCenterClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr MigrationCenterClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr MigrationCenterClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status MigrationCenterClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status MigrationCenterClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status MigrationCenterClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status MigrationCenterClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..4e074483b4a21 100644 --- a/google/cloud/migrationcenter/v1/migration_center_client.h +++ b/google/cloud/migrationcenter/v1/migration_center_client.h @@ -4363,6 +4363,356 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..d6b5eb14a3281 100644 --- a/google/cloud/migrationcenter/v1/migration_center_connection.cc +++ b/google/cloud/migrationcenter/v1/migration_center_connection.cc @@ -741,6 +741,44 @@ 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"); +} + +StreamRange +MigrationCenterConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +MigrationCenterConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status MigrationCenterConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status MigrationCenterConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeMigrationCenterConnection( Options options) { internal::CheckExpectedOptions> DeleteReport(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..4bd222ff0a1ee 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,36 @@ 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; +} + +Idempotency MigrationCenterConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency MigrationCenterConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency MigrationCenterConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency MigrationCenterConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..af1b8725a3875 100644 --- a/google/cloud/migrationcenter/v1/migration_center_connection_idempotency_policy.h +++ b/google/cloud/migrationcenter/v1/migration_center_connection_idempotency_policy.h @@ -21,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -200,6 +202,24 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..2e35c075a3feb 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,29 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..717e177ffeb5a 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,56 @@ 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); +} + +StatusOr +NetAppAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr NetAppAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status NetAppAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status NetAppAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..47da3fdbf556d 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..0081ed5816f45 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,125 @@ 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__); +} + +StreamRange +NetAppConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr NetAppConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status NetAppConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status NetAppConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..5ed67a4e80628 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..38ceefe74eb14 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,74 @@ 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_); +} + +StatusOr +NetAppLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr NetAppLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status NetAppLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status NetAppLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..3e1b219d9fc21 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..13e2b6fd3d176 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,56 @@ 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); +} + +StatusOr +NetAppMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr NetAppMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status NetAppMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status NetAppMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..31149acfffff7 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..c295652728372 100644 --- a/google/cloud/netapp/v1/internal/net_app_stub.cc +++ b/google/cloud/netapp/v1/internal/net_app_stub.cc @@ -1199,6 +1199,74 @@ 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; +} + +StatusOr +DefaultNetAppStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultNetAppStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultNetAppStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultNetAppStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..60c989450cdff 100644 --- a/google/cloud/netapp/v1/internal/net_app_stub.h +++ b/google/cloud/netapp/v1/internal/net_app_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 @@ -469,6 +470,31 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -487,9 +513,16 @@ class DefaultNetAppStub : public NetAppStub { DefaultNetAppStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListStoragePools(grpc::ClientContext& context, Options const& options, @@ -939,6 +972,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -953,6 +1010,10 @@ class DefaultNetAppStub : public NetAppStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..3ffe3c4c942a6 100644 --- a/google/cloud/netapp/v1/internal/net_app_stub_factory.cc +++ b/google/cloud/netapp/v1/internal/net_app_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 @@ -43,8 +45,13 @@ 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_operations_stub = + google::longrunning::Operations::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_operations_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..fbd16a67215f3 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,57 @@ 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)); +} + +StreamRange +NetAppTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan("netapp_v1::NetAppConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr NetAppTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan("netapp_v1::NetAppConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status NetAppTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = + internal::MakeSpan("netapp_v1::NetAppConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status NetAppTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("netapp_v1::NetAppConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..a7f1d45567945 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..bf86ee8934ade 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,74 @@ 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)); +} + +StatusOr +NetAppTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.netapp.v1.NetApp", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr NetAppTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.netapp.v1.NetApp", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status NetAppTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.netapp.v1.NetApp", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status NetAppTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.netapp.v1.NetApp", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..3a7478e22f0d4 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..07668b8cbcc57 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,29 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..cdf723f860d9e 100644 --- a/google/cloud/netapp/v1/net_app_client.cc +++ b/google/cloud/netapp/v1/net_app_client.cc @@ -1578,6 +1578,73 @@ 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); +} + +StreamRange NetAppClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange NetAppClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr NetAppClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr NetAppClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status NetAppClient::DeleteOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status NetAppClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status NetAppClient::CancelOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status NetAppClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..4561f583451a4 100644 --- a/google/cloud/netapp/v1/net_app_client.h +++ b/google/cloud/netapp/v1/net_app_client.h @@ -4839,6 +4839,356 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..4a54a72a86570 100644 --- a/google/cloud/netapp/v1/net_app_connection.cc +++ b/google/cloud/netapp/v1/net_app_connection.cc @@ -845,6 +845,40 @@ 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"); +} + +StreamRange NetAppConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr NetAppConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status NetAppConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status NetAppConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeNetAppConnection(Options options) { internal::CheckExpectedOptions> DeleteBackupPolicy(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..866601897b351 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,36 @@ 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; +} + +Idempotency NetAppConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency NetAppConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency NetAppConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency NetAppConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..382d9acdfcff3 100644 --- a/google/cloud/netapp/v1/net_app_connection_idempotency_policy.h +++ b/google/cloud/netapp/v1/net_app_connection_idempotency_policy.h @@ -21,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -189,6 +191,24 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..6c2b3c67a7be3 100644 --- a/google/cloud/networkconnectivity/v1/hub_client.cc +++ b/google/cloud/networkconnectivity/v1/hub_client.cc @@ -559,6 +559,94 @@ 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); +} + +StreamRange HubServiceClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange HubServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr HubServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr HubServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status HubServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status HubServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status HubServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status HubServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..60daccaa6660c 100644 --- a/google/cloud/networkconnectivity/v1/hub_client.h +++ b/google/cloud/networkconnectivity/v1/hub_client.h @@ -1777,6 +1777,458 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..bbfc7fe5f91cf 100644 --- a/google/cloud/networkconnectivity/v1/hub_connection.cc +++ b/google/cloud/networkconnectivity/v1/hub_connection.cc @@ -292,6 +292,58 @@ 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"); +} + +StreamRange +HubServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr HubServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status HubServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status HubServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeHubServiceConnection( Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..0901869393581 100644 --- a/google/cloud/networkconnectivity/v1/hub_connection_idempotency_policy.cc +++ b/google/cloud/networkconnectivity/v1/hub_connection_idempotency_policy.cc @@ -129,6 +129,52 @@ 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; +} + +Idempotency HubServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency HubServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency HubServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency HubServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..7882624034c87 100644 --- a/google/cloud/networkconnectivity/v1/hub_connection_idempotency_policy.h +++ b/google/cloud/networkconnectivity/v1/hub_connection_idempotency_policy.h @@ -21,7 +21,10 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include +#include #include namespace google { @@ -98,6 +101,33 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..3856b8ee0961a 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_auth_decorator.cc +++ b/google/cloud/networkconnectivity/v1/internal/hub_auth_decorator.cc @@ -357,6 +357,81 @@ 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); +} + +StatusOr +HubServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr HubServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status HubServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status HubServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..87d51fc624cc8 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_auth_decorator.h +++ b/google/cloud/networkconnectivity/v1/internal/hub_auth_decorator.h @@ -192,6 +192,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..17c96a01c024c 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_connection_impl.cc +++ b/google/cloud/networkconnectivity/v1/internal/hub_connection_impl.cc @@ -1101,6 +1101,166 @@ 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__); +} + +StreamRange +HubServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr HubServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status HubServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status HubServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..1d620e7fae765 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_connection_impl.h +++ b/google/cloud/networkconnectivity/v1/internal/hub_connection_impl.h @@ -197,6 +197,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..66ef776b169bb 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_logging_decorator.cc +++ b/google/cloud/networkconnectivity/v1/internal/hub_logging_decorator.cc @@ -435,6 +435,108 @@ 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_); +} + +StatusOr +HubServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr HubServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status HubServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status HubServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..b5740f0683859 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_logging_decorator.h +++ b/google/cloud/networkconnectivity/v1/internal/hub_logging_decorator.h @@ -192,6 +192,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..642af8ba79d96 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_metadata_decorator.cc +++ b/google/cloud/networkconnectivity/v1/internal/hub_metadata_decorator.cc @@ -314,6 +314,84 @@ 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); +} + +StatusOr +HubServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr HubServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status HubServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status HubServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..a1ca84da07f51 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_metadata_decorator.h +++ b/google/cloud/networkconnectivity/v1/internal/hub_metadata_decorator.h @@ -192,6 +192,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..67cf18c2987c3 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_stub.cc +++ b/google/cloud/networkconnectivity/v1/internal/hub_stub.cc @@ -412,6 +412,109 @@ 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; +} + +StatusOr +DefaultHubServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultHubServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultHubServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultHubServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..5c1015af648db 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_stub.h +++ b/google/cloud/networkconnectivity/v1/internal/hub_stub.h @@ -24,8 +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 @@ -194,6 +196,44 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -213,9 +253,18 @@ class DefaultHubServiceStub : public HubServiceStub { std::unique_ptr< google::cloud::networkconnectivity::v1::HubService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +419,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -386,6 +471,11 @@ class DefaultHubServiceStub : public HubServiceStub { std::unique_ptr< google::cloud::networkconnectivity::v1::HubService::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..e17f813f78959 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_stub_factory.cc +++ b/google/cloud/networkconnectivity/v1/internal/hub_stub_factory.cc @@ -28,7 +28,10 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultHubServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::networkconnectivity::v1::HubService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..f5dd9ff165fb8 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_tracing_connection.cc +++ b/google/cloud/networkconnectivity/v1/internal/hub_tracing_connection.cc @@ -378,6 +378,87 @@ 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)); +} + +StreamRange +HubServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "networkconnectivity_v1::HubServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +HubServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "networkconnectivity_v1::HubServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status HubServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "networkconnectivity_v1::HubServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status HubServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "networkconnectivity_v1::HubServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..6450f0899b7ff 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_tracing_connection.h +++ b/google/cloud/networkconnectivity/v1/internal/hub_tracing_connection.h @@ -185,6 +185,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..1dae7b6ca94ab 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_tracing_stub.cc +++ b/google/cloud/networkconnectivity/v1/internal/hub_tracing_stub.cc @@ -373,6 +373,108 @@ 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)); +} + +StatusOr +HubServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkconnectivity.v1.HubService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr HubServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkconnectivity.v1.HubService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status HubServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkconnectivity.v1.HubService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status HubServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkconnectivity.v1.HubService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..c16ad20f35b0c 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_tracing_stub.h +++ b/google/cloud/networkconnectivity/v1/internal/hub_tracing_stub.h @@ -191,6 +191,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..bb76fd4b15b24 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,83 @@ 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); +} + +StatusOr +PolicyBasedRoutingServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +PolicyBasedRoutingServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status PolicyBasedRoutingServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status PolicyBasedRoutingServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..2af808c611b29 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..93b7f24e59d7a 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,171 @@ 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__); +} + +StreamRange +PolicyBasedRoutingServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +PolicyBasedRoutingServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status PolicyBasedRoutingServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status PolicyBasedRoutingServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..c1d69e610659f 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..e6625c18565ec 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,112 @@ 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_); +} + +StatusOr +PolicyBasedRoutingServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +PolicyBasedRoutingServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status PolicyBasedRoutingServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status PolicyBasedRoutingServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..b313a50cb88f4 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..0d02f27b12003 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,88 @@ 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); +} + +StatusOr +PolicyBasedRoutingServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +PolicyBasedRoutingServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status PolicyBasedRoutingServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status PolicyBasedRoutingServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..593fcda6f43ab 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..42d0a886897fe 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,113 @@ 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; +} + +StatusOr +DefaultPolicyBasedRoutingServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPolicyBasedRoutingServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultPolicyBasedRoutingServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultPolicyBasedRoutingServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..d2b0f6fed3075 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,9 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include +#include #include #include #include @@ -76,6 +78,44 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -96,9 +136,18 @@ class DefaultPolicyBasedRoutingServiceStub std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +186,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -153,6 +238,11 @@ class DefaultPolicyBasedRoutingServiceStub std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..f57e2a7efa225 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,10 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include +#include +#include #include #include @@ -45,9 +48,15 @@ CreateDefaultPolicyBasedRoutingServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::networkconnectivity::v1:: PolicyBasedRoutingService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..ed95b8e45951c 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,98 @@ 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)); +} + +StreamRange +PolicyBasedRoutingServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "networkconnectivity_v1::PolicyBasedRoutingServiceConnection::" + "ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +PolicyBasedRoutingServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "networkconnectivity_v1::PolicyBasedRoutingServiceConnection::" + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status PolicyBasedRoutingServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "networkconnectivity_v1::PolicyBasedRoutingServiceConnection::" + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status PolicyBasedRoutingServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "networkconnectivity_v1::PolicyBasedRoutingServiceConnection::" + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..224fd7fdb3637 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..b3c9d1de51693 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,121 @@ 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)); +} + +StatusOr +PolicyBasedRoutingServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkconnectivity.v1.PolicyBasedRoutingService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +PolicyBasedRoutingServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkconnectivity.v1.PolicyBasedRoutingService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status PolicyBasedRoutingServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkconnectivity.v1.PolicyBasedRoutingService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status PolicyBasedRoutingServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkconnectivity.v1.PolicyBasedRoutingService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..19830dda88364 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..806ce1b65997e 100644 --- a/google/cloud/networkconnectivity/v1/mocks/mock_hub_connection.h +++ b/google/cloud/networkconnectivity/v1/mocks/mock_hub_connection.h @@ -431,6 +431,42 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..0d13fc2e4be8f 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,42 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..2f0ccf9da9ac1 100644 --- a/google/cloud/networkconnectivity/v1/policy_based_routing_client.cc +++ b/google/cloud/networkconnectivity/v1/policy_based_routing_client.cc @@ -168,6 +168,101 @@ 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); +} + +StreamRange +PolicyBasedRoutingServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +PolicyBasedRoutingServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +PolicyBasedRoutingServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +PolicyBasedRoutingServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status PolicyBasedRoutingServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status PolicyBasedRoutingServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status PolicyBasedRoutingServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status PolicyBasedRoutingServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..c32414d127ca7 100644 --- a/google/cloud/networkconnectivity/v1/policy_based_routing_client.h +++ b/google/cloud/networkconnectivity/v1/policy_based_routing_client.h @@ -466,6 +466,458 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..92b734b7224c6 100644 --- a/google/cloud/networkconnectivity/v1/policy_based_routing_connection.cc +++ b/google/cloud/networkconnectivity/v1/policy_based_routing_connection.cc @@ -103,6 +103,62 @@ 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"); +} + +StreamRange +PolicyBasedRoutingServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +PolicyBasedRoutingServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status PolicyBasedRoutingServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status PolicyBasedRoutingServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakePolicyBasedRoutingServiceConnection(Options options) { internal::CheckExpectedOptions> 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..5dbe429d40b6a 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,56 @@ 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; +} + +Idempotency +PolicyBasedRoutingServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency PolicyBasedRoutingServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +PolicyBasedRoutingServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency +PolicyBasedRoutingServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..84c2e96a78e5f 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,10 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include +#include #include namespace google { @@ -52,6 +55,33 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..435592b760fd4 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_auth_decorator.cc +++ b/google/cloud/networkmanagement/v1/internal/reachability_auth_decorator.cc @@ -175,6 +175,82 @@ 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); +} + +StatusOr +ReachabilityServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr ReachabilityServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status ReachabilityServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status ReachabilityServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..1a41e6a8ef605 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_auth_decorator.h +++ b/google/cloud/networkmanagement/v1/internal/reachability_auth_decorator.h @@ -99,6 +99,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..e0341200283b1 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_connection_impl.cc +++ b/google/cloud/networkmanagement/v1/internal/reachability_connection_impl.cc @@ -507,6 +507,171 @@ 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__); +} + +StreamRange +ReachabilityServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ReachabilityServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ReachabilityServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ReachabilityServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..a2082e24c26a9 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_connection_impl.h +++ b/google/cloud/networkmanagement/v1/internal/reachability_connection_impl.h @@ -119,6 +119,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..544009fdfefa6 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_logging_decorator.cc +++ b/google/cloud/networkmanagement/v1/internal/reachability_logging_decorator.cc @@ -199,6 +199,110 @@ 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_); +} + +StatusOr +ReachabilityServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ReachabilityServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ReachabilityServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ReachabilityServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..97239bd386be4 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_logging_decorator.h +++ b/google/cloud/networkmanagement/v1/internal/reachability_logging_decorator.h @@ -99,6 +99,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..595951f7ded16 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_metadata_decorator.cc +++ b/google/cloud/networkmanagement/v1/internal/reachability_metadata_decorator.cc @@ -158,6 +158,86 @@ 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); +} + +StatusOr +ReachabilityServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +ReachabilityServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status ReachabilityServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status ReachabilityServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..b4217c8d8c416 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_metadata_decorator.h +++ b/google/cloud/networkmanagement/v1/internal/reachability_metadata_decorator.h @@ -100,6 +100,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..25cffb8de0eff 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_stub.cc +++ b/google/cloud/networkmanagement/v1/internal/reachability_stub.cc @@ -192,6 +192,111 @@ 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; +} + +StatusOr +DefaultReachabilityServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultReachabilityServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultReachabilityServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultReachabilityServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..b00ea03039e97 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_stub.h +++ b/google/cloud/networkmanagement/v1/internal/reachability_stub.h @@ -24,7 +24,9 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include +#include #include #include #include @@ -103,6 +105,44 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -122,9 +162,18 @@ class DefaultReachabilityServiceStub : public ReachabilityServiceStub { std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListConnectivityTests( @@ -186,6 +235,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -202,6 +287,11 @@ class DefaultReachabilityServiceStub : public ReachabilityServiceStub { std::unique_ptr< google::cloud::networkmanagement::v1::ReachabilityService::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..53146d8ac1a1d 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_stub_factory.cc +++ b/google/cloud/networkmanagement/v1/internal/reachability_stub_factory.cc @@ -28,7 +28,10 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include +#include +#include #include #include @@ -45,9 +48,15 @@ std::shared_ptr CreateDefaultReachabilityServiceStub( auto service_grpc_stub = google::cloud::networkmanagement::v1::ReachabilityService::NewStub( channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..45cb400869c6e 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_tracing_connection.cc +++ b/google/cloud/networkmanagement/v1/internal/reachability_tracing_connection.cc @@ -202,6 +202,90 @@ 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)); +} + +StreamRange +ReachabilityServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "networkmanagement_v1::ReachabilityServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ReachabilityServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "networkmanagement_v1::ReachabilityServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status ReachabilityServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "networkmanagement_v1::ReachabilityServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status ReachabilityServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "networkmanagement_v1::ReachabilityServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..29e88e06d44d6 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_tracing_connection.h +++ b/google/cloud/networkmanagement/v1/internal/reachability_tracing_connection.h @@ -107,6 +107,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..5d90d5f708bb7 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_tracing_stub.cc +++ b/google/cloud/networkmanagement/v1/internal/reachability_tracing_stub.cc @@ -187,6 +187,114 @@ 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)); +} + +StatusOr +ReachabilityServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkmanagement.v1.ReachabilityService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +ReachabilityServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkmanagement.v1.ReachabilityService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status ReachabilityServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkmanagement.v1.ReachabilityService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status ReachabilityServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkmanagement.v1.ReachabilityService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..72a4b5a56dd8c 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_tracing_stub.h +++ b/google/cloud/networkmanagement/v1/internal/reachability_tracing_stub.h @@ -99,6 +99,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..e9608b8fd1c64 100644 --- a/google/cloud/networkmanagement/v1/mocks/mock_reachability_connection.h +++ b/google/cloud/networkmanagement/v1/mocks/mock_reachability_connection.h @@ -222,6 +222,42 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..96b5f17bb73f9 100644 --- a/google/cloud/networkmanagement/v1/reachability_client.cc +++ b/google/cloud/networkmanagement/v1/reachability_client.cc @@ -240,6 +240,100 @@ 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); +} + +StreamRange +ReachabilityServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +ReachabilityServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +ReachabilityServiceClient::GetOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +ReachabilityServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status ReachabilityServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status ReachabilityServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status ReachabilityServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status ReachabilityServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..9e286e9227883 100644 --- a/google/cloud/networkmanagement/v1/reachability_client.h +++ b/google/cloud/networkmanagement/v1/reachability_client.h @@ -735,6 +735,458 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..fc77e4da8780c 100644 --- a/google/cloud/networkmanagement/v1/reachability_connection.cc +++ b/google/cloud/networkmanagement/v1/reachability_connection.cc @@ -151,6 +151,60 @@ 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"); +} + +StreamRange +ReachabilityServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +ReachabilityServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ReachabilityServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ReachabilityServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeReachabilityServiceConnection(Options options) { internal::CheckExpectedOptions> 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..dd6829a69edea 100644 --- a/google/cloud/networkmanagement/v1/reachability_connection_idempotency_policy.cc +++ b/google/cloud/networkmanagement/v1/reachability_connection_idempotency_policy.cc @@ -74,6 +74,52 @@ 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; +} + +Idempotency ReachabilityServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ReachabilityServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ReachabilityServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency ReachabilityServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..2d95b71e7df01 100644 --- a/google/cloud/networkmanagement/v1/reachability_connection_idempotency_policy.h +++ b/google/cloud/networkmanagement/v1/reachability_connection_idempotency_policy.h @@ -21,7 +21,10 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include +#include #include namespace google { @@ -60,6 +63,33 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..ed6424b93edb9 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,81 @@ 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); +} + +StatusOr +NetworkSecurityAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr NetworkSecurityAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status NetworkSecurityAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status NetworkSecurityAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..22d5f9d3bf803 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..e2b62aca1117b 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,167 @@ 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__); +} + +StreamRange +NetworkSecurityConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +NetworkSecurityConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status NetworkSecurityConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status NetworkSecurityConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..9cf54949b88a9 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..748a21c1ba4ed 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,108 @@ 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_); +} + +StatusOr +NetworkSecurityLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr NetworkSecurityLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status NetworkSecurityLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status NetworkSecurityLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..e27bb17138f65 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..c17532b8f4ec1 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,85 @@ 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); +} + +StatusOr +NetworkSecurityMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr NetworkSecurityMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status NetworkSecurityMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status NetworkSecurityMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..21e5f0afe2e04 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..f9038b7868267 100644 --- a/google/cloud/networksecurity/v1/internal/network_security_stub.cc +++ b/google/cloud/networksecurity/v1/internal/network_security_stub.cc @@ -412,6 +412,111 @@ 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; +} + +StatusOr +DefaultNetworkSecurityStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultNetworkSecurityStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultNetworkSecurityStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultNetworkSecurityStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..6abc7d83f760a 100644 --- a/google/cloud/networksecurity/v1/internal/network_security_stub.h +++ b/google/cloud/networksecurity/v1/internal/network_security_stub.h @@ -24,8 +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 @@ -195,6 +197,44 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -214,9 +254,18 @@ class DefaultNetworkSecurityStub : public NetworkSecurityStub { std::unique_ptr< google::cloud::networksecurity::v1::NetworkSecurity::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +415,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -382,6 +467,11 @@ class DefaultNetworkSecurityStub : public NetworkSecurityStub { std::unique_ptr< google::cloud::networksecurity::v1::NetworkSecurity::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..98ff9993bcf4a 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,10 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultNetworkSecurityStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::networksecurity::v1::NetworkSecurity::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..83c2a4edda198 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,89 @@ 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)); +} + +StreamRange +NetworkSecurityTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "networksecurity_v1::NetworkSecurityConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +NetworkSecurityTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "networksecurity_v1::NetworkSecurityConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status NetworkSecurityTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "networksecurity_v1::NetworkSecurityConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status NetworkSecurityTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "networksecurity_v1::NetworkSecurityConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..b85cbf92baa11 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..c84aa0ec60150 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,110 @@ 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)); +} + +StatusOr +NetworkSecurityTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networksecurity.v1.NetworkSecurity", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +NetworkSecurityTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networksecurity.v1.NetworkSecurity", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status NetworkSecurityTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networksecurity.v1.NetworkSecurity", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status NetworkSecurityTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networksecurity.v1.NetworkSecurity", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..1a466ecbbf119 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..dfadf08660722 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,42 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..8c15cba7a5319 100644 --- a/google/cloud/networksecurity/v1/network_security_client.cc +++ b/google/cloud/networksecurity/v1/network_security_client.cc @@ -588,6 +588,97 @@ 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); +} + +StreamRange +NetworkSecurityClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +NetworkSecurityClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr NetworkSecurityClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr NetworkSecurityClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status NetworkSecurityClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status NetworkSecurityClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status NetworkSecurityClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status NetworkSecurityClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..547a528e62619 100644 --- a/google/cloud/networksecurity/v1/network_security_client.h +++ b/google/cloud/networksecurity/v1/network_security_client.h @@ -1613,6 +1613,458 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..bee4aa3946186 100644 --- a/google/cloud/networksecurity/v1/network_security_connection.cc +++ b/google/cloud/networksecurity/v1/network_security_connection.cc @@ -299,6 +299,60 @@ 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"); +} + +StreamRange +NetworkSecurityConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +NetworkSecurityConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status NetworkSecurityConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status NetworkSecurityConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeNetworkSecurityConnection( Options options) { internal::CheckExpectedOptions> 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..8e8d54a2d858d 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,52 @@ 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; +} + +Idempotency NetworkSecurityConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency NetworkSecurityConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency NetworkSecurityConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency NetworkSecurityConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..e9693649b51fc 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,10 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include +#include #include namespace google { @@ -94,6 +97,33 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..7811b21a4762b 100644 --- a/google/cloud/networkservices/v1/dep_client.cc +++ b/google/cloud/networkservices/v1/dep_client.cc @@ -398,6 +398,94 @@ 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); +} + +StreamRange DepServiceClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange DepServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr DepServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr DepServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status DepServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status DepServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status DepServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status DepServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..0b83e692c978a 100644 --- a/google/cloud/networkservices/v1/dep_client.h +++ b/google/cloud/networkservices/v1/dep_client.h @@ -1107,6 +1107,458 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..05771f78ed4ec 100644 --- a/google/cloud/networkservices/v1/dep_connection.cc +++ b/google/cloud/networkservices/v1/dep_connection.cc @@ -213,6 +213,58 @@ 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"); +} + +StreamRange +DepServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr DepServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DepServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DepServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDepServiceConnection( Options options) { internal::CheckExpectedOptions> 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..f4c76084b5ed0 100644 --- a/google/cloud/networkservices/v1/dep_connection_idempotency_policy.cc +++ b/google/cloud/networkservices/v1/dep_connection_idempotency_policy.cc @@ -89,6 +89,52 @@ 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; +} + +Idempotency DepServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DepServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DepServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency DepServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..e952385d3d68e 100644 --- a/google/cloud/networkservices/v1/dep_connection_idempotency_policy.h +++ b/google/cloud/networkservices/v1/dep_connection_idempotency_policy.h @@ -21,7 +21,10 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include +#include #include namespace google { @@ -74,6 +77,33 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..1b6c7b57999d9 100644 --- a/google/cloud/networkservices/v1/internal/dep_auth_decorator.cc +++ b/google/cloud/networkservices/v1/internal/dep_auth_decorator.cc @@ -254,6 +254,81 @@ 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); +} + +StatusOr +DepServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr DepServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status DepServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status DepServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..6f077706f3316 100644 --- a/google/cloud/networkservices/v1/internal/dep_auth_decorator.h +++ b/google/cloud/networkservices/v1/internal/dep_auth_decorator.h @@ -138,6 +138,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..6489133ddbba2 100644 --- a/google/cloud/networkservices/v1/internal/dep_connection_impl.cc +++ b/google/cloud/networkservices/v1/internal/dep_connection_impl.cc @@ -742,6 +742,166 @@ 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__); +} + +StreamRange +DepServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr DepServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DepServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DepServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..6dfc50f7dd37c 100644 --- a/google/cloud/networkservices/v1/internal/dep_connection_impl.h +++ b/google/cloud/networkservices/v1/internal/dep_connection_impl.h @@ -156,6 +156,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..2cde6c5cf2eb9 100644 --- a/google/cloud/networkservices/v1/internal/dep_logging_decorator.cc +++ b/google/cloud/networkservices/v1/internal/dep_logging_decorator.cc @@ -296,6 +296,108 @@ 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_); +} + +StatusOr +DepServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DepServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DepServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DepServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..05086a8f6dfc7 100644 --- a/google/cloud/networkservices/v1/internal/dep_logging_decorator.h +++ b/google/cloud/networkservices/v1/internal/dep_logging_decorator.h @@ -138,6 +138,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..e673fb2390a9d 100644 --- a/google/cloud/networkservices/v1/internal/dep_metadata_decorator.cc +++ b/google/cloud/networkservices/v1/internal/dep_metadata_decorator.cc @@ -230,6 +230,84 @@ 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); +} + +StatusOr +DepServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr DepServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status DepServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status DepServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..1281944d1c9b6 100644 --- a/google/cloud/networkservices/v1/internal/dep_metadata_decorator.h +++ b/google/cloud/networkservices/v1/internal/dep_metadata_decorator.h @@ -138,6 +138,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..8e299b3fb3e06 100644 --- a/google/cloud/networkservices/v1/internal/dep_stub.cc +++ b/google/cloud/networkservices/v1/internal/dep_stub.cc @@ -288,6 +288,109 @@ 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; +} + +StatusOr +DefaultDepServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultDepServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultDepServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultDepServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..00dcb058330d2 100644 --- a/google/cloud/networkservices/v1/internal/dep_stub.h +++ b/google/cloud/networkservices/v1/internal/dep_stub.h @@ -24,7 +24,9 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include +#include #include #include #include @@ -142,6 +144,44 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -161,9 +201,18 @@ class DefaultDepServiceStub : public DepServiceStub { std::unique_ptr< google::cloud::networkservices::v1::DepService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListLbTrafficExtensions( @@ -264,6 +313,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -279,6 +364,11 @@ class DefaultDepServiceStub : public DepServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..7d81cf80d0340 100644 --- a/google/cloud/networkservices/v1/internal/dep_stub_factory.cc +++ b/google/cloud/networkservices/v1/internal/dep_stub_factory.cc @@ -28,7 +28,10 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultDepServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::networkservices::v1::DepService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..ad77b533dd6ea 100644 --- a/google/cloud/networkservices/v1/internal/dep_tracing_connection.cc +++ b/google/cloud/networkservices/v1/internal/dep_tracing_connection.cc @@ -276,6 +276,87 @@ 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)); +} + +StreamRange +DepServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "networkservices_v1::DepServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DepServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "networkservices_v1::DepServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status DepServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "networkservices_v1::DepServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status DepServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "networkservices_v1::DepServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..78fcce9244d20 100644 --- a/google/cloud/networkservices/v1/internal/dep_tracing_connection.h +++ b/google/cloud/networkservices/v1/internal/dep_tracing_connection.h @@ -144,6 +144,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..bf0c2fdd383f0 100644 --- a/google/cloud/networkservices/v1/internal/dep_tracing_stub.cc +++ b/google/cloud/networkservices/v1/internal/dep_tracing_stub.cc @@ -265,6 +265,108 @@ 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)); +} + +StatusOr +DepServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkservices.v1.DepService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr DepServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkservices.v1.DepService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status DepServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkservices.v1.DepService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status DepServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkservices.v1.DepService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..09547028b36be 100644 --- a/google/cloud/networkservices/v1/internal/dep_tracing_stub.h +++ b/google/cloud/networkservices/v1/internal/dep_tracing_stub.h @@ -137,6 +137,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..a7bbb14e00edf 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,81 @@ 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); +} + +StatusOr +NetworkServicesAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr NetworkServicesAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status NetworkServicesAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status NetworkServicesAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..e3bf747912df8 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..407ee1de829a8 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,167 @@ 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__); +} + +StreamRange +NetworkServicesConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +NetworkServicesConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status NetworkServicesConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status NetworkServicesConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..0b14d51fd4043 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..2faa01e1df31c 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,108 @@ 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_); +} + +StatusOr +NetworkServicesLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr NetworkServicesLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status NetworkServicesLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status NetworkServicesLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..40bee01f4c481 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..b815312a8f901 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,85 @@ 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); +} + +StatusOr +NetworkServicesMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr NetworkServicesMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status NetworkServicesMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status NetworkServicesMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..53e4cf309bb11 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..5d5e9fbdc7b67 100644 --- a/google/cloud/networkservices/v1/internal/network_services_stub.cc +++ b/google/cloud/networkservices/v1/internal/network_services_stub.cc @@ -952,6 +952,111 @@ 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; +} + +StatusOr +DefaultNetworkServicesStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultNetworkServicesStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultNetworkServicesStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultNetworkServicesStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..abcce63a94a9b 100644 --- a/google/cloud/networkservices/v1/internal/network_services_stub.h +++ b/google/cloud/networkservices/v1/internal/network_services_stub.h @@ -24,7 +24,9 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include +#include #include #include #include @@ -399,6 +401,44 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -418,9 +458,18 @@ class DefaultNetworkServicesStub : public NetworkServicesStub { std::unique_ptr< google::cloud::networkservices::v1::NetworkServices::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListEndpointPolicies( @@ -784,6 +833,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -800,6 +885,11 @@ class DefaultNetworkServicesStub : public NetworkServicesStub { std::unique_ptr< google::cloud::networkservices::v1::NetworkServices::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..7e12033078794 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,10 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultNetworkServicesStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::networkservices::v1::NetworkServices::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..dc1dbe1a62147 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,89 @@ 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)); +} + +StreamRange +NetworkServicesTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "networkservices_v1::NetworkServicesConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +NetworkServicesTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "networkservices_v1::NetworkServicesConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status NetworkServicesTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "networkservices_v1::NetworkServicesConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status NetworkServicesTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "networkservices_v1::NetworkServicesConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..559eee1533802 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..6e4a4f5e6f723 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,110 @@ 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)); +} + +StatusOr +NetworkServicesTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkservices.v1.NetworkServices", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +NetworkServicesTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkservices.v1.NetworkServices", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status NetworkServicesTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkservices.v1.NetworkServices", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status NetworkServicesTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkservices.v1.NetworkServices", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..da22633392c60 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..93cbe0df5382b 100644 --- a/google/cloud/networkservices/v1/mocks/mock_dep_connection.h +++ b/google/cloud/networkservices/v1/mocks/mock_dep_connection.h @@ -326,6 +326,42 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..0e9ddab1a2582 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,42 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..f52cb7f7d7479 100644 --- a/google/cloud/networkservices/v1/network_services_client.cc +++ b/google/cloud/networkservices/v1/network_services_client.cc @@ -1319,6 +1319,97 @@ 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); +} + +StreamRange +NetworkServicesClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +NetworkServicesClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr NetworkServicesClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr NetworkServicesClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status NetworkServicesClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status NetworkServicesClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status NetworkServicesClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status NetworkServicesClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..06dbdbaedb48d 100644 --- a/google/cloud/networkservices/v1/network_services_client.h +++ b/google/cloud/networkservices/v1/network_services_client.h @@ -3891,6 +3891,458 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..d8c6c93ab4289 100644 --- a/google/cloud/networkservices/v1/network_services_connection.cc +++ b/google/cloud/networkservices/v1/network_services_connection.cc @@ -693,6 +693,60 @@ 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"); +} + +StreamRange +NetworkServicesConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +NetworkServicesConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status NetworkServicesConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status NetworkServicesConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeNetworkServicesConnection( Options options) { internal::CheckExpectedOptions> 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..39cdbec12c781 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,52 @@ 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; +} + +Idempotency NetworkServicesConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency NetworkServicesConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency NetworkServicesConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency NetworkServicesConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..1e624efac4bdd 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,10 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include +#include #include namespace google { @@ -166,6 +169,33 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..0085878d73413 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,83 @@ 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); +} + +StatusOr +ManagedNotebookServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +ManagedNotebookServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status ManagedNotebookServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status ManagedNotebookServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..583354fc681bf 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..3213e78950215 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,169 @@ 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__); +} + +StreamRange +ManagedNotebookServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ManagedNotebookServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ManagedNotebookServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ManagedNotebookServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..c73f99ea8e637 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..f593ff2b8f30e 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,110 @@ 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_); +} + +StatusOr +ManagedNotebookServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ManagedNotebookServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ManagedNotebookServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ManagedNotebookServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..e9d9b8fbdf5ff 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..bc370e7e72951 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,86 @@ 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); +} + +StatusOr +ManagedNotebookServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +ManagedNotebookServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status ManagedNotebookServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status ManagedNotebookServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..70a0172f75fd3 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..b288006f6f989 100644 --- a/google/cloud/notebooks/v1/internal/managed_notebook_stub.cc +++ b/google/cloud/notebooks/v1/internal/managed_notebook_stub.cc @@ -371,6 +371,113 @@ 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; +} + +StatusOr +DefaultManagedNotebookServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultManagedNotebookServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultManagedNotebookServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultManagedNotebookServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..98a0738ed65f1 100644 --- a/google/cloud/notebooks/v1/internal/managed_notebook_stub.h +++ b/google/cloud/notebooks/v1/internal/managed_notebook_stub.h @@ -24,8 +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 @@ -158,6 +160,44 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -177,9 +217,18 @@ class DefaultManagedNotebookServiceStub : public ManagedNotebookServiceStub { std::unique_ptr< google::cloud::notebooks::v1::ManagedNotebookService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +363,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -330,6 +415,11 @@ class DefaultManagedNotebookServiceStub : public ManagedNotebookServiceStub { std::unique_ptr< google::cloud::notebooks::v1::ManagedNotebookService::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..6de06de822f99 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,10 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include +#include +#include #include #include @@ -45,9 +48,15 @@ CreateDefaultManagedNotebookServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::notebooks::v1::ManagedNotebookService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..de9314c009ea6 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,89 @@ 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)); +} + +StreamRange +ManagedNotebookServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "notebooks_v1::ManagedNotebookServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ManagedNotebookServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "notebooks_v1::ManagedNotebookServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status ManagedNotebookServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "notebooks_v1::ManagedNotebookServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status ManagedNotebookServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "notebooks_v1::ManagedNotebookServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..3d4a1d88e0f52 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..0145be708ecd5 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,112 @@ 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)); +} + +StatusOr +ManagedNotebookServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.notebooks.v1.ManagedNotebookService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +ManagedNotebookServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.notebooks.v1.ManagedNotebookService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status ManagedNotebookServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.notebooks.v1.ManagedNotebookService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status ManagedNotebookServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.notebooks.v1.ManagedNotebookService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..d267092bb351d 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..f2217ffa394bf 100644 --- a/google/cloud/notebooks/v1/internal/notebook_auth_decorator.cc +++ b/google/cloud/notebooks/v1/internal/notebook_auth_decorator.cc @@ -789,6 +789,81 @@ 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); +} + +StatusOr +NotebookServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr NotebookServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status NotebookServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status NotebookServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..77d438e9ac3c2 100644 --- a/google/cloud/notebooks/v1/internal/notebook_auth_decorator.h +++ b/google/cloud/notebooks/v1/internal/notebook_auth_decorator.h @@ -372,6 +372,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..cc0fa37658a7f 100644 --- a/google/cloud/notebooks/v1/internal/notebook_connection_impl.cc +++ b/google/cloud/notebooks/v1/internal/notebook_connection_impl.cc @@ -2421,6 +2421,167 @@ 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__); +} + +StreamRange +NotebookServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +NotebookServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status NotebookServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status NotebookServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..724dae3ee8ca7 100644 --- a/google/cloud/notebooks/v1/internal/notebook_connection_impl.h +++ b/google/cloud/notebooks/v1/internal/notebook_connection_impl.h @@ -378,6 +378,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..3d04ce2cc28bb 100644 --- a/google/cloud/notebooks/v1/internal/notebook_logging_decorator.cc +++ b/google/cloud/notebooks/v1/internal/notebook_logging_decorator.cc @@ -911,6 +911,108 @@ 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_); +} + +StatusOr +NotebookServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr NotebookServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status NotebookServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status NotebookServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..56b4043a53428 100644 --- a/google/cloud/notebooks/v1/internal/notebook_logging_decorator.h +++ b/google/cloud/notebooks/v1/internal/notebook_logging_decorator.h @@ -372,6 +372,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..774de3c20653f 100644 --- a/google/cloud/notebooks/v1/internal/notebook_metadata_decorator.cc +++ b/google/cloud/notebooks/v1/internal/notebook_metadata_decorator.cc @@ -633,6 +633,85 @@ 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); +} + +StatusOr +NotebookServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr NotebookServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status NotebookServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status NotebookServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..2c8df58bd0ebb 100644 --- a/google/cloud/notebooks/v1/internal/notebook_metadata_decorator.h +++ b/google/cloud/notebooks/v1/internal/notebook_metadata_decorator.h @@ -373,6 +373,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..9010d41704d4f 100644 --- a/google/cloud/notebooks/v1/internal/notebook_stub.cc +++ b/google/cloud/notebooks/v1/internal/notebook_stub.cc @@ -884,6 +884,111 @@ 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; +} + +StatusOr +DefaultNotebookServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultNotebookServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultNotebookServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultNotebookServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..307431f687679 100644 --- a/google/cloud/notebooks/v1/internal/notebook_stub.h +++ b/google/cloud/notebooks/v1/internal/notebook_stub.h @@ -24,8 +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 @@ -354,6 +356,44 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -373,9 +413,18 @@ class DefaultNotebookServiceStub : public NotebookServiceStub { std::unique_ptr< google::cloud::notebooks::v1::NotebookService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +759,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -725,6 +810,11 @@ class DefaultNotebookServiceStub : public NotebookServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..e578331d78ffd 100644 --- a/google/cloud/notebooks/v1/internal/notebook_stub_factory.cc +++ b/google/cloud/notebooks/v1/internal/notebook_stub_factory.cc @@ -28,7 +28,10 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultNotebookServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::notebooks::v1::NotebookService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..c9dfcafa248fa 100644 --- a/google/cloud/notebooks/v1/internal/notebook_tracing_connection.cc +++ b/google/cloud/notebooks/v1/internal/notebook_tracing_connection.cc @@ -832,6 +832,89 @@ 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)); +} + +StreamRange +NotebookServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "notebooks_v1::NotebookServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +NotebookServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "notebooks_v1::NotebookServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status NotebookServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "notebooks_v1::NotebookServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status NotebookServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "notebooks_v1::NotebookServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..f37f037a2a6a0 100644 --- a/google/cloud/notebooks/v1/internal/notebook_tracing_connection.h +++ b/google/cloud/notebooks/v1/internal/notebook_tracing_connection.h @@ -366,6 +366,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..f4e68db60c46a 100644 --- a/google/cloud/notebooks/v1/internal/notebook_tracing_stub.cc +++ b/google/cloud/notebooks/v1/internal/notebook_tracing_stub.cc @@ -799,6 +799,110 @@ 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)); +} + +StatusOr +NotebookServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.notebooks.v1.NotebookService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +NotebookServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.notebooks.v1.NotebookService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status NotebookServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.notebooks.v1.NotebookService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status NotebookServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.notebooks.v1.NotebookService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..e4e85e9e22d89 100644 --- a/google/cloud/notebooks/v1/internal/notebook_tracing_stub.h +++ b/google/cloud/notebooks/v1/internal/notebook_tracing_stub.h @@ -372,6 +372,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..f34b57fbe225c 100644 --- a/google/cloud/notebooks/v1/managed_notebook_client.cc +++ b/google/cloud/notebooks/v1/managed_notebook_client.cc @@ -521,6 +521,101 @@ 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); +} + +StreamRange +ManagedNotebookServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +ManagedNotebookServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +ManagedNotebookServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +ManagedNotebookServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status ManagedNotebookServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status ManagedNotebookServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status ManagedNotebookServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status ManagedNotebookServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..62823dfea981c 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,458 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..14bef6b8d9960 100644 --- a/google/cloud/notebooks/v1/managed_notebook_connection.cc +++ b/google/cloud/notebooks/v1/managed_notebook_connection.cc @@ -289,6 +289,62 @@ 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"); +} + +StreamRange +ManagedNotebookServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +ManagedNotebookServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ManagedNotebookServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ManagedNotebookServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeManagedNotebookServiceConnection(Options options) { internal::CheckExpectedOptions> 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..2ff646e577137 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,53 @@ 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; +} + +Idempotency ManagedNotebookServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ManagedNotebookServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ManagedNotebookServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency ManagedNotebookServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..814c370d2a44c 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,10 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include +#include #include namespace google { @@ -76,6 +79,33 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..83659aebffc5b 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,42 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..48d902d22cad7 100644 --- a/google/cloud/notebooks/v1/mocks/mock_notebook_connection.h +++ b/google/cloud/notebooks/v1/mocks/mock_notebook_connection.h @@ -1005,6 +1005,42 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..49fd1d2be9c95 100644 --- a/google/cloud/notebooks/v1/notebook_client.cc +++ b/google/cloud/notebooks/v1/notebook_client.cc @@ -926,6 +926,97 @@ 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); +} + +StreamRange +NotebookServiceClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +NotebookServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr NotebookServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr NotebookServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status NotebookServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status NotebookServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status NotebookServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status NotebookServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..92a913a42a1c6 100644 --- a/google/cloud/notebooks/v1/notebook_client.h +++ b/google/cloud/notebooks/v1/notebook_client.h @@ -2741,6 +2741,458 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..09267a84590fe 100644 --- a/google/cloud/notebooks/v1/notebook_connection.cc +++ b/google/cloud/notebooks/v1/notebook_connection.cc @@ -646,6 +646,60 @@ 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"); +} + +StreamRange +NotebookServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +NotebookServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status NotebookServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status NotebookServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeNotebookServiceConnection( Options options) { internal::CheckExpectedOptions> 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..0975cf0cf71ac 100644 --- a/google/cloud/notebooks/v1/notebook_connection_idempotency_policy.cc +++ b/google/cloud/notebooks/v1/notebook_connection_idempotency_policy.cc @@ -206,6 +206,52 @@ 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; +} + +Idempotency NotebookServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency NotebookServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency NotebookServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency NotebookServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..0b6c2d38e4078 100644 --- a/google/cloud/notebooks/v1/notebook_connection_idempotency_policy.h +++ b/google/cloud/notebooks/v1/notebook_connection_idempotency_policy.h @@ -21,7 +21,10 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include +#include #include namespace google { @@ -144,6 +147,33 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..d427e48a6290a 100644 --- a/google/cloud/notebooks/v2/internal/notebook_auth_decorator.cc +++ b/google/cloud/notebooks/v2/internal/notebook_auth_decorator.cc @@ -311,6 +311,81 @@ 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); +} + +StatusOr +NotebookServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr NotebookServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status NotebookServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status NotebookServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..93172b35dcf72 100644 --- a/google/cloud/notebooks/v2/internal/notebook_auth_decorator.h +++ b/google/cloud/notebooks/v2/internal/notebook_auth_decorator.h @@ -162,6 +162,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..20b893b507496 100644 --- a/google/cloud/notebooks/v2/internal/notebook_connection_impl.cc +++ b/google/cloud/notebooks/v2/internal/notebook_connection_impl.cc @@ -952,6 +952,167 @@ 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__); +} + +StreamRange +NotebookServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +NotebookServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status NotebookServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status NotebookServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..01c855a3dd52a 100644 --- a/google/cloud/notebooks/v2/internal/notebook_connection_impl.h +++ b/google/cloud/notebooks/v2/internal/notebook_connection_impl.h @@ -171,6 +171,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..4a8aa38a0f015 100644 --- a/google/cloud/notebooks/v2/internal/notebook_logging_decorator.cc +++ b/google/cloud/notebooks/v2/internal/notebook_logging_decorator.cc @@ -355,6 +355,108 @@ 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_); +} + +StatusOr +NotebookServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr NotebookServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status NotebookServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status NotebookServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..fbb9c01dcb892 100644 --- a/google/cloud/notebooks/v2/internal/notebook_logging_decorator.h +++ b/google/cloud/notebooks/v2/internal/notebook_logging_decorator.h @@ -162,6 +162,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..6c40195db01a4 100644 --- a/google/cloud/notebooks/v2/internal/notebook_metadata_decorator.cc +++ b/google/cloud/notebooks/v2/internal/notebook_metadata_decorator.cc @@ -261,6 +261,85 @@ 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); +} + +StatusOr +NotebookServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr NotebookServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status NotebookServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status NotebookServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..9390f99263324 100644 --- a/google/cloud/notebooks/v2/internal/notebook_metadata_decorator.h +++ b/google/cloud/notebooks/v2/internal/notebook_metadata_decorator.h @@ -163,6 +163,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..4dc3541fa02a2 100644 --- a/google/cloud/notebooks/v2/internal/notebook_stub.cc +++ b/google/cloud/notebooks/v2/internal/notebook_stub.cc @@ -342,6 +342,111 @@ 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; +} + +StatusOr +DefaultNotebookServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultNotebookServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultNotebookServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultNotebookServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..fa5b8c46249fe 100644 --- a/google/cloud/notebooks/v2/internal/notebook_stub.h +++ b/google/cloud/notebooks/v2/internal/notebook_stub.h @@ -24,7 +24,9 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include +#include #include #include #include @@ -146,6 +148,44 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -165,9 +205,18 @@ class DefaultNotebookServiceStub : public NotebookServiceStub { std::unique_ptr< google::cloud::notebooks::v2::NotebookService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_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 +341,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -307,6 +392,11 @@ class DefaultNotebookServiceStub : public NotebookServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..35a18b2ffaada 100644 --- a/google/cloud/notebooks/v2/internal/notebook_stub_factory.cc +++ b/google/cloud/notebooks/v2/internal/notebook_stub_factory.cc @@ -28,7 +28,10 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultNotebookServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::notebooks::v2::NotebookService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..a8dd89301de3e 100644 --- a/google/cloud/notebooks/v2/internal/notebook_tracing_connection.cc +++ b/google/cloud/notebooks/v2/internal/notebook_tracing_connection.cc @@ -323,6 +323,89 @@ 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)); +} + +StreamRange +NotebookServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "notebooks_v2::NotebookServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +NotebookServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "notebooks_v2::NotebookServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status NotebookServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "notebooks_v2::NotebookServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status NotebookServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "notebooks_v2::NotebookServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..731b10c943177 100644 --- a/google/cloud/notebooks/v2/internal/notebook_tracing_connection.h +++ b/google/cloud/notebooks/v2/internal/notebook_tracing_connection.h @@ -159,6 +159,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..ccd2d9466602c 100644 --- a/google/cloud/notebooks/v2/internal/notebook_tracing_stub.cc +++ b/google/cloud/notebooks/v2/internal/notebook_tracing_stub.cc @@ -311,6 +311,110 @@ 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)); +} + +StatusOr +NotebookServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.notebooks.v2.NotebookService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +NotebookServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.notebooks.v2.NotebookService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status NotebookServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.notebooks.v2.NotebookService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status NotebookServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.notebooks.v2.NotebookService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..983cb55e315fc 100644 --- a/google/cloud/notebooks/v2/internal/notebook_tracing_stub.h +++ b/google/cloud/notebooks/v2/internal/notebook_tracing_stub.h @@ -162,6 +162,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..748c1bf4ca8d6 100644 --- a/google/cloud/notebooks/v2/mocks/mock_notebook_connection.h +++ b/google/cloud/notebooks/v2/mocks/mock_notebook_connection.h @@ -408,6 +408,42 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..ecdae1074483b 100644 --- a/google/cloud/notebooks/v2/notebook_client.cc +++ b/google/cloud/notebooks/v2/notebook_client.cc @@ -367,6 +367,97 @@ 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); +} + +StreamRange +NotebookServiceClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +NotebookServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr NotebookServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr NotebookServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status NotebookServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status NotebookServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status NotebookServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status NotebookServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..0cbca005bb714 100644 --- a/google/cloud/notebooks/v2/notebook_client.h +++ b/google/cloud/notebooks/v2/notebook_client.h @@ -1050,6 +1050,458 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..193e8a677ab08 100644 --- a/google/cloud/notebooks/v2/notebook_connection.cc +++ b/google/cloud/notebooks/v2/notebook_connection.cc @@ -264,6 +264,60 @@ 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"); +} + +StreamRange +NotebookServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +NotebookServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status NotebookServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status NotebookServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeNotebookServiceConnection( Options options) { internal::CheckExpectedOptions> 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..90ba2069046ed 100644 --- a/google/cloud/notebooks/v2/notebook_connection_idempotency_policy.cc +++ b/google/cloud/notebooks/v2/notebook_connection_idempotency_policy.cc @@ -95,6 +95,52 @@ 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; +} + +Idempotency NotebookServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency NotebookServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency NotebookServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency NotebookServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..74754bd4ab416 100644 --- a/google/cloud/notebooks/v2/notebook_connection_idempotency_policy.h +++ b/google/cloud/notebooks/v2/notebook_connection_idempotency_policy.h @@ -21,7 +21,10 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include +#include #include namespace google { @@ -73,6 +76,33 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/optimization/v1/fleet_routing_client.cc b/google/cloud/optimization/v1/fleet_routing_client.cc index 3c8c839dbbd2d..5111bdd9a81da 100644 --- a/google/cloud/optimization/v1/fleet_routing_client.cc +++ b/google/cloud/optimization/v1/fleet_routing_client.cc @@ -63,6 +63,20 @@ FleetRoutingClient::BatchOptimizeTours( return connection_->BatchOptimizeTours(operation); } +StatusOr FleetRoutingClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr FleetRoutingClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace optimization_v1 } // namespace cloud diff --git a/google/cloud/optimization/v1/fleet_routing_client.h b/google/cloud/optimization/v1/fleet_routing_client.h index 240cd4a3a0d6b..51a1c18cd1caf 100644 --- a/google/cloud/optimization/v1/fleet_routing_client.h +++ b/google/cloud/optimization/v1/fleet_routing_client.h @@ -225,6 +225,66 @@ class FleetRoutingClient { BatchOptimizeTours(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/optimization/v1/fleet_routing_connection.cc b/google/cloud/optimization/v1/fleet_routing_connection.cc index e67f22af0b7a9..cc7d70cf08139 100644 --- a/google/cloud/optimization/v1/fleet_routing_connection.cc +++ b/google/cloud/optimization/v1/fleet_routing_connection.cc @@ -67,6 +67,11 @@ FleetRoutingConnection::BatchOptimizeTours( Status(StatusCode::kUnimplemented, "not implemented")); } +StatusOr FleetRoutingConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeFleetRoutingConnection( Options options) { internal::CheckExpectedOptions> BatchOptimizeTours(google::longrunning::Operation const& operation); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/optimization/v1/fleet_routing_connection_idempotency_policy.cc b/google/cloud/optimization/v1/fleet_routing_connection_idempotency_policy.cc index 26e1b123acdab..f6a337d894c6c 100644 --- a/google/cloud/optimization/v1/fleet_routing_connection_idempotency_policy.cc +++ b/google/cloud/optimization/v1/fleet_routing_connection_idempotency_policy.cc @@ -44,6 +44,11 @@ Idempotency FleetRoutingConnectionIdempotencyPolicy::BatchOptimizeTours( return Idempotency::kNonIdempotent; } +Idempotency FleetRoutingConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultFleetRoutingConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/optimization/v1/fleet_routing_connection_idempotency_policy.h b/google/cloud/optimization/v1/fleet_routing_connection_idempotency_policy.h index 237d04a09bfef..c9c74a6f95cb6 100644 --- a/google/cloud/optimization/v1/fleet_routing_connection_idempotency_policy.h +++ b/google/cloud/optimization/v1/fleet_routing_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -43,6 +44,9 @@ class FleetRoutingConnectionIdempotencyPolicy { virtual google::cloud::Idempotency BatchOptimizeTours( google::cloud::optimization::v1::BatchOptimizeToursRequest const& request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/optimization/v1/internal/fleet_routing_auth_decorator.cc b/google/cloud/optimization/v1/internal/fleet_routing_auth_decorator.cc index 44f84002cf238..70aa6517a53ce 100644 --- a/google/cloud/optimization/v1/internal/fleet_routing_auth_decorator.cc +++ b/google/cloud/optimization/v1/internal/fleet_routing_auth_decorator.cc @@ -68,6 +68,14 @@ StatusOr FleetRoutingAuth::BatchOptimizeTours( return child_->BatchOptimizeTours(context, options, request); } +StatusOr FleetRoutingAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + future> FleetRoutingAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/optimization/v1/internal/fleet_routing_auth_decorator.h b/google/cloud/optimization/v1/internal/fleet_routing_auth_decorator.h index cf93ead9fec85..ceca64c42b3ee 100644 --- a/google/cloud/optimization/v1/internal/fleet_routing_auth_decorator.h +++ b/google/cloud/optimization/v1/internal/fleet_routing_auth_decorator.h @@ -56,6 +56,10 @@ class FleetRoutingAuth : public FleetRoutingStub { google::cloud::optimization::v1::BatchOptimizeToursRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/optimization/v1/internal/fleet_routing_connection_impl.cc b/google/cloud/optimization/v1/internal/fleet_routing_connection_impl.cc index a50bc8c048ca9..20108d821a3fd 100644 --- a/google/cloud/optimization/v1/internal/fleet_routing_connection_impl.cc +++ b/google/cloud/optimization/v1/internal/fleet_routing_connection_impl.cc @@ -174,6 +174,20 @@ FleetRoutingConnectionImpl::BatchOptimizeTours( polling_policy(*current), __func__); } +StatusOr +FleetRoutingConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace optimization_v1_internal } // namespace cloud diff --git a/google/cloud/optimization/v1/internal/fleet_routing_connection_impl.h b/google/cloud/optimization/v1/internal/fleet_routing_connection_impl.h index 6f7f762f3e636..78d761dfb76d4 100644 --- a/google/cloud/optimization/v1/internal/fleet_routing_connection_impl.h +++ b/google/cloud/optimization/v1/internal/fleet_routing_connection_impl.h @@ -68,6 +68,9 @@ class FleetRoutingConnectionImpl future> BatchOptimizeTours(google::longrunning::Operation const& operation) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/optimization/v1/internal/fleet_routing_logging_decorator.cc b/google/cloud/optimization/v1/internal/fleet_routing_logging_decorator.cc index 35c2de67a74a9..5f191dbd6189b 100644 --- a/google/cloud/optimization/v1/internal/fleet_routing_logging_decorator.cc +++ b/google/cloud/optimization/v1/internal/fleet_routing_logging_decorator.cc @@ -80,6 +80,17 @@ FleetRoutingLogging::BatchOptimizeTours( context, options, request, __func__, tracing_options_); } +StatusOr FleetRoutingLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> FleetRoutingLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/optimization/v1/internal/fleet_routing_logging_decorator.h b/google/cloud/optimization/v1/internal/fleet_routing_logging_decorator.h index 35c3cab904205..8b4858fbebb2b 100644 --- a/google/cloud/optimization/v1/internal/fleet_routing_logging_decorator.h +++ b/google/cloud/optimization/v1/internal/fleet_routing_logging_decorator.h @@ -56,6 +56,10 @@ class FleetRoutingLogging : public FleetRoutingStub { google::cloud::optimization::v1::BatchOptimizeToursRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/optimization/v1/internal/fleet_routing_metadata_decorator.cc b/google/cloud/optimization/v1/internal/fleet_routing_metadata_decorator.cc index d0df8b040916f..a4d8d4a19562a 100644 --- a/google/cloud/optimization/v1/internal/fleet_routing_metadata_decorator.cc +++ b/google/cloud/optimization/v1/internal/fleet_routing_metadata_decorator.cc @@ -74,6 +74,14 @@ FleetRoutingMetadata::BatchOptimizeTours( return child_->BatchOptimizeTours(context, options, request); } +StatusOr FleetRoutingMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + future> FleetRoutingMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/optimization/v1/internal/fleet_routing_metadata_decorator.h b/google/cloud/optimization/v1/internal/fleet_routing_metadata_decorator.h index 16c06c92e0086..e44f246dc6288 100644 --- a/google/cloud/optimization/v1/internal/fleet_routing_metadata_decorator.h +++ b/google/cloud/optimization/v1/internal/fleet_routing_metadata_decorator.h @@ -56,6 +56,10 @@ class FleetRoutingMetadata : public FleetRoutingStub { google::cloud::optimization::v1::BatchOptimizeToursRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/optimization/v1/internal/fleet_routing_stub.cc b/google/cloud/optimization/v1/internal/fleet_routing_stub.cc index 663cf4e5c7f8e..bd93cd9f8547b 100644 --- a/google/cloud/optimization/v1/internal/fleet_routing_stub.cc +++ b/google/cloud/optimization/v1/internal/fleet_routing_stub.cc @@ -74,6 +74,17 @@ DefaultFleetRoutingStub::BatchOptimizeTours( return response; } +StatusOr DefaultFleetRoutingStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultFleetRoutingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/optimization/v1/internal/fleet_routing_stub.h b/google/cloud/optimization/v1/internal/fleet_routing_stub.h index 70cfffd71753f..3b06ba3f70fb6 100644 --- a/google/cloud/optimization/v1/internal/fleet_routing_stub.h +++ b/google/cloud/optimization/v1/internal/fleet_routing_stub.h @@ -56,6 +56,10 @@ class FleetRoutingStub { google::cloud::optimization::v1::BatchOptimizeToursRequest const& request) = 0; + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -75,9 +79,13 @@ class DefaultFleetRoutingStub : public FleetRoutingStub { std::unique_ptr< google::cloud::optimization::v1::FleetRouting::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr OptimizeTours(grpc::ClientContext& context, Options const& options, @@ -96,6 +104,10 @@ class DefaultFleetRoutingStub : public FleetRoutingStub { google::cloud::optimization::v1::BatchOptimizeToursRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -111,6 +123,8 @@ class DefaultFleetRoutingStub : public FleetRoutingStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/optimization/v1/internal/fleet_routing_stub_factory.cc b/google/cloud/optimization/v1/internal/fleet_routing_stub_factory.cc index ac520bc7e1752..64b2459eb70c6 100644 --- a/google/cloud/optimization/v1/internal/fleet_routing_stub_factory.cc +++ b/google/cloud/optimization/v1/internal/fleet_routing_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 CreateDefaultFleetRoutingStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::optimization::v1::FleetRouting::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/optimization/v1/internal/fleet_routing_tracing_connection.cc b/google/cloud/optimization/v1/internal/fleet_routing_tracing_connection.cc index 93da7df57fa14..431f8a34b7678 100644 --- a/google/cloud/optimization/v1/internal/fleet_routing_tracing_connection.cc +++ b/google/cloud/optimization/v1/internal/fleet_routing_tracing_connection.cc @@ -72,6 +72,15 @@ FleetRoutingTracingConnection::BatchOptimizeTours( child_->BatchOptimizeTours(operation)); } +StatusOr +FleetRoutingTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "optimization_v1::FleetRoutingConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/optimization/v1/internal/fleet_routing_tracing_connection.h b/google/cloud/optimization/v1/internal/fleet_routing_tracing_connection.h index aac826dc351ee..da337f4e74fbe 100644 --- a/google/cloud/optimization/v1/internal/fleet_routing_tracing_connection.h +++ b/google/cloud/optimization/v1/internal/fleet_routing_tracing_connection.h @@ -57,6 +57,9 @@ class FleetRoutingTracingConnection future> BatchOptimizeTours(google::longrunning::Operation const& operation) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/optimization/v1/internal/fleet_routing_tracing_stub.cc b/google/cloud/optimization/v1/internal/fleet_routing_tracing_stub.cc index c5e9a771a7d62..ae3dfca5e7822 100644 --- a/google/cloud/optimization/v1/internal/fleet_routing_tracing_stub.cc +++ b/google/cloud/optimization/v1/internal/fleet_routing_tracing_stub.cc @@ -71,6 +71,17 @@ FleetRoutingTracingStub::BatchOptimizeTours( context, *span, child_->BatchOptimizeTours(context, options, request)); } +StatusOr FleetRoutingTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.optimization.v1.FleetRouting", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + future> FleetRoutingTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/optimization/v1/internal/fleet_routing_tracing_stub.h b/google/cloud/optimization/v1/internal/fleet_routing_tracing_stub.h index d4100a94f33b6..56d673ff901e9 100644 --- a/google/cloud/optimization/v1/internal/fleet_routing_tracing_stub.h +++ b/google/cloud/optimization/v1/internal/fleet_routing_tracing_stub.h @@ -55,6 +55,10 @@ class FleetRoutingTracingStub : public FleetRoutingStub { google::cloud::optimization::v1::BatchOptimizeToursRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/optimization/v1/mocks/mock_fleet_routing_connection.h b/google/cloud/optimization/v1/mocks/mock_fleet_routing_connection.h index fb2631b788334..d38c827d6281f 100644 --- a/google/cloud/optimization/v1/mocks/mock_fleet_routing_connection.h +++ b/google/cloud/optimization/v1/mocks/mock_fleet_routing_connection.h @@ -93,6 +93,10 @@ class MockFleetRoutingConnection google::cloud::optimization::v1::BatchOptimizeToursResponse>>, BatchOptimizeTours, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/policysimulator/v1/internal/simulator_auth_decorator.cc b/google/cloud/policysimulator/v1/internal/simulator_auth_decorator.cc index 470bd5d982324..2f71825d7b270 100644 --- a/google/cloud/policysimulator/v1/internal/simulator_auth_decorator.cc +++ b/google/cloud/policysimulator/v1/internal/simulator_auth_decorator.cc @@ -77,6 +77,23 @@ SimulatorAuth::ListReplayResults( return child_->ListReplayResults(context, options, request); } +StatusOr +SimulatorAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr SimulatorAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + future> SimulatorAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/policysimulator/v1/internal/simulator_auth_decorator.h b/google/cloud/policysimulator/v1/internal/simulator_auth_decorator.h index 054dd7d52ba6b..78140ff2e06e1 100644 --- a/google/cloud/policysimulator/v1/internal/simulator_auth_decorator.h +++ b/google/cloud/policysimulator/v1/internal/simulator_auth_decorator.h @@ -62,6 +62,14 @@ class SimulatorAuth : public SimulatorStub { google::cloud::policysimulator::v1::ListReplayResultsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/policysimulator/v1/internal/simulator_connection_impl.cc b/google/cloud/policysimulator/v1/internal/simulator_connection_impl.cc index a97e8d687f008..522e45f91c411 100644 --- a/google/cloud/policysimulator/v1/internal/simulator_connection_impl.cc +++ b/google/cloud/policysimulator/v1/internal/simulator_connection_impl.cc @@ -209,6 +209,52 @@ SimulatorConnectionImpl::ListReplayResults( }); } +StreamRange +SimulatorConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr SimulatorConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace policysimulator_v1_internal } // namespace cloud diff --git a/google/cloud/policysimulator/v1/internal/simulator_connection_impl.h b/google/cloud/policysimulator/v1/internal/simulator_connection_impl.h index b61b94837591a..e0cd6f2675958 100644 --- a/google/cloud/policysimulator/v1/internal/simulator_connection_impl.h +++ b/google/cloud/policysimulator/v1/internal/simulator_connection_impl.h @@ -71,6 +71,12 @@ class SimulatorConnectionImpl : public policysimulator_v1::SimulatorConnection { ListReplayResults(google::cloud::policysimulator::v1::ListReplayResultsRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/policysimulator/v1/internal/simulator_logging_decorator.cc b/google/cloud/policysimulator/v1/internal/simulator_logging_decorator.cc index 12ed000128445..9ce155f886bff 100644 --- a/google/cloud/policysimulator/v1/internal/simulator_logging_decorator.cc +++ b/google/cloud/policysimulator/v1/internal/simulator_logging_decorator.cc @@ -93,6 +93,29 @@ SimulatorLogging::ListReplayResults( context, options, request, __func__, tracing_options_); } +StatusOr +SimulatorLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr SimulatorLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> SimulatorLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/policysimulator/v1/internal/simulator_logging_decorator.h b/google/cloud/policysimulator/v1/internal/simulator_logging_decorator.h index 90a4dc1665406..b0494a41d0994 100644 --- a/google/cloud/policysimulator/v1/internal/simulator_logging_decorator.h +++ b/google/cloud/policysimulator/v1/internal/simulator_logging_decorator.h @@ -62,6 +62,14 @@ class SimulatorLogging : public SimulatorStub { google::cloud::policysimulator::v1::ListReplayResultsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/policysimulator/v1/internal/simulator_metadata_decorator.cc b/google/cloud/policysimulator/v1/internal/simulator_metadata_decorator.cc index c443479101f8d..ff2ca6740160e 100644 --- a/google/cloud/policysimulator/v1/internal/simulator_metadata_decorator.cc +++ b/google/cloud/policysimulator/v1/internal/simulator_metadata_decorator.cc @@ -83,6 +83,23 @@ SimulatorMetadata::ListReplayResults( return child_->ListReplayResults(context, options, request); } +StatusOr +SimulatorMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr SimulatorMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + future> SimulatorMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/policysimulator/v1/internal/simulator_metadata_decorator.h b/google/cloud/policysimulator/v1/internal/simulator_metadata_decorator.h index f3b9686ecc4a0..46115f514bdee 100644 --- a/google/cloud/policysimulator/v1/internal/simulator_metadata_decorator.h +++ b/google/cloud/policysimulator/v1/internal/simulator_metadata_decorator.h @@ -62,6 +62,14 @@ class SimulatorMetadata : public SimulatorStub { google::cloud::policysimulator::v1::ListReplayResultsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/policysimulator/v1/internal/simulator_stub.cc b/google/cloud/policysimulator/v1/internal/simulator_stub.cc index 00fe6019113fe..ab9d2abacad65 100644 --- a/google/cloud/policysimulator/v1/internal/simulator_stub.cc +++ b/google/cloud/policysimulator/v1/internal/simulator_stub.cc @@ -86,6 +86,29 @@ DefaultSimulatorStub::ListReplayResults( return response; } +StatusOr +DefaultSimulatorStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultSimulatorStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultSimulatorStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/policysimulator/v1/internal/simulator_stub.h b/google/cloud/policysimulator/v1/internal/simulator_stub.h index aa60fe60eca74..c18e6502745bc 100644 --- a/google/cloud/policysimulator/v1/internal/simulator_stub.h +++ b/google/cloud/policysimulator/v1/internal/simulator_stub.h @@ -61,6 +61,14 @@ class SimulatorStub { google::cloud::policysimulator::v1::ListReplayResultsRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -80,9 +88,13 @@ class DefaultSimulatorStub : public SimulatorStub { std::unique_ptr< google::cloud::policysimulator::v1::Simulator::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr GetReplay( grpc::ClientContext& context, Options const& options, @@ -107,6 +119,14 @@ class DefaultSimulatorStub : public SimulatorStub { google::cloud::policysimulator::v1::ListReplayResultsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -122,6 +142,8 @@ class DefaultSimulatorStub : public SimulatorStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/policysimulator/v1/internal/simulator_stub_factory.cc b/google/cloud/policysimulator/v1/internal/simulator_stub_factory.cc index ac5e7e244d419..099b146b057ba 100644 --- a/google/cloud/policysimulator/v1/internal/simulator_stub_factory.cc +++ b/google/cloud/policysimulator/v1/internal/simulator_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 CreateDefaultSimulatorStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::policysimulator::v1::Simulator::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/policysimulator/v1/internal/simulator_tracing_connection.cc b/google/cloud/policysimulator/v1/internal/simulator_tracing_connection.cc index 11ca5b18d8c98..60306974a00dc 100644 --- a/google/cloud/policysimulator/v1/internal/simulator_tracing_connection.cc +++ b/google/cloud/policysimulator/v1/internal/simulator_tracing_connection.cc @@ -82,6 +82,26 @@ SimulatorTracingConnection::ListReplayResults( std::move(sr)); } +StreamRange +SimulatorTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "policysimulator_v1::SimulatorConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +SimulatorTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "policysimulator_v1::SimulatorConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/policysimulator/v1/internal/simulator_tracing_connection.h b/google/cloud/policysimulator/v1/internal/simulator_tracing_connection.h index 638414738f592..fa0fcc14beb4b 100644 --- a/google/cloud/policysimulator/v1/internal/simulator_tracing_connection.h +++ b/google/cloud/policysimulator/v1/internal/simulator_tracing_connection.h @@ -60,6 +60,12 @@ class SimulatorTracingConnection ListReplayResults(google::cloud::policysimulator::v1::ListReplayResultsRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/policysimulator/v1/internal/simulator_tracing_stub.cc b/google/cloud/policysimulator/v1/internal/simulator_tracing_stub.cc index 803cdd07e2773..32437b26ba3fb 100644 --- a/google/cloud/policysimulator/v1/internal/simulator_tracing_stub.cc +++ b/google/cloud/policysimulator/v1/internal/simulator_tracing_stub.cc @@ -81,6 +81,29 @@ SimulatorTracingStub::ListReplayResults( context, *span, child_->ListReplayResults(context, options, request)); } +StatusOr +SimulatorTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.policysimulator.v1.Simulator", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr SimulatorTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.policysimulator.v1.Simulator", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + future> SimulatorTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/policysimulator/v1/internal/simulator_tracing_stub.h b/google/cloud/policysimulator/v1/internal/simulator_tracing_stub.h index 55a1aca53da79..c7ad1d2f86019 100644 --- a/google/cloud/policysimulator/v1/internal/simulator_tracing_stub.h +++ b/google/cloud/policysimulator/v1/internal/simulator_tracing_stub.h @@ -61,6 +61,14 @@ class SimulatorTracingStub : public SimulatorStub { google::cloud::policysimulator::v1::ListReplayResultsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/policysimulator/v1/mocks/mock_simulator_connection.h b/google/cloud/policysimulator/v1/mocks/mock_simulator_connection.h index 4165cb8ab0b62..e7974a107a1fd 100644 --- a/google/cloud/policysimulator/v1/mocks/mock_simulator_connection.h +++ b/google/cloud/policysimulator/v1/mocks/mock_simulator_connection.h @@ -95,6 +95,13 @@ class MockSimulatorConnection : public policysimulator_v1::SimulatorConnection { ListReplayResults, (google::cloud::policysimulator::v1::ListReplayResultsRequest request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/policysimulator/v1/simulator_client.cc b/google/cloud/policysimulator/v1/simulator_client.cc index e0964063a5958..3edda67bccf54 100644 --- a/google/cloud/policysimulator/v1/simulator_client.cc +++ b/google/cloud/policysimulator/v1/simulator_client.cc @@ -107,6 +107,35 @@ SimulatorClient::ListReplayResults( return connection_->ListReplayResults(std::move(request)); } +StreamRange SimulatorClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange SimulatorClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr SimulatorClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr SimulatorClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace policysimulator_v1 } // namespace cloud diff --git a/google/cloud/policysimulator/v1/simulator_client.h b/google/cloud/policysimulator/v1/simulator_client.h index fdaaa5a91e035..4d6d0928f3653 100644 --- a/google/cloud/policysimulator/v1/simulator_client.h +++ b/google/cloud/policysimulator/v1/simulator_client.h @@ -376,6 +376,158 @@ class SimulatorClient { google::cloud::policysimulator::v1::ListReplayResultsRequest request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/policysimulator/v1/simulator_connection.cc b/google/cloud/policysimulator/v1/simulator_connection.cc index b774e7c14d5aa..2d82d12e76491 100644 --- a/google/cloud/policysimulator/v1/simulator_connection.cc +++ b/google/cloud/policysimulator/v1/simulator_connection.cc @@ -74,6 +74,18 @@ SimulatorConnection::ListReplayResults( StreamRange>(); } +StreamRange SimulatorConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr SimulatorConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSimulatorConnection(Options options) { internal::CheckExpectedOptions ListReplayResults( google::cloud::policysimulator::v1::ListReplayResultsRequest request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/policysimulator/v1/simulator_connection_idempotency_policy.cc b/google/cloud/policysimulator/v1/simulator_connection_idempotency_policy.cc index ee079543492aa..07807d673890b 100644 --- a/google/cloud/policysimulator/v1/simulator_connection_idempotency_policy.cc +++ b/google/cloud/policysimulator/v1/simulator_connection_idempotency_policy.cc @@ -49,6 +49,16 @@ Idempotency SimulatorConnectionIdempotencyPolicy::ListReplayResults( return Idempotency::kIdempotent; } +Idempotency SimulatorConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SimulatorConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultSimulatorConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/policysimulator/v1/simulator_connection_idempotency_policy.h b/google/cloud/policysimulator/v1/simulator_connection_idempotency_policy.h index 7f78e4aa399c4..f67b9e67f5310 100644 --- a/google/cloud/policysimulator/v1/simulator_connection_idempotency_policy.h +++ b/google/cloud/policysimulator/v1/simulator_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 SimulatorConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListReplayResults( google::cloud::policysimulator::v1::ListReplayResultsRequest request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest 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..c77b171e5d4fc 100644 --- a/google/cloud/privateca/v1/certificate_authority_client.cc +++ b/google/cloud/privateca/v1/certificate_authority_client.cc @@ -1003,6 +1003,103 @@ 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); +} + +StreamRange +CertificateAuthorityServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +CertificateAuthorityServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +CertificateAuthorityServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +CertificateAuthorityServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status CertificateAuthorityServiceClient::DeleteOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status CertificateAuthorityServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status CertificateAuthorityServiceClient::CancelOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status CertificateAuthorityServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..7316dd376703b 100644 --- a/google/cloud/privateca/v1/certificate_authority_client.h +++ b/google/cloud/privateca/v1/certificate_authority_client.h @@ -2926,6 +2926,458 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..50d3fc127fa43 100644 --- a/google/cloud/privateca/v1/certificate_authority_connection.cc +++ b/google/cloud/privateca/v1/certificate_authority_connection.cc @@ -493,6 +493,62 @@ 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"); +} + +StreamRange +CertificateAuthorityServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +CertificateAuthorityServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status CertificateAuthorityServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status CertificateAuthorityServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeCertificateAuthorityServiceConnection(Options options) { internal::CheckExpectedOptions> 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..26630fd93ebaf 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,60 @@ 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; +} + +Idempotency +CertificateAuthorityServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency +CertificateAuthorityServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +CertificateAuthorityServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency +CertificateAuthorityServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..3a04c0021de40 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,10 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include +#include #include namespace google { @@ -150,6 +153,33 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..fe25633cd3c02 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,83 @@ 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); +} + +StatusOr +CertificateAuthorityServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +CertificateAuthorityServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status CertificateAuthorityServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status CertificateAuthorityServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..cd7dad2153119 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..1b5fb4176a19c 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,171 @@ 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__); +} + +StreamRange +CertificateAuthorityServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +CertificateAuthorityServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status CertificateAuthorityServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status CertificateAuthorityServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..9a6cc20097414 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..f0cb3dd30b154 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,112 @@ 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_); +} + +StatusOr +CertificateAuthorityServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +CertificateAuthorityServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status CertificateAuthorityServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status CertificateAuthorityServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..48c040ecd60b4 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..0c48c924d077d 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,88 @@ 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); +} + +StatusOr +CertificateAuthorityServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +CertificateAuthorityServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status CertificateAuthorityServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status CertificateAuthorityServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..9610e87e8c6ec 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..a8296f1f4706e 100644 --- a/google/cloud/privateca/v1/internal/certificate_authority_stub.cc +++ b/google/cloud/privateca/v1/internal/certificate_authority_stub.cc @@ -720,6 +720,113 @@ 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; +} + +StatusOr +DefaultCertificateAuthorityServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultCertificateAuthorityServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultCertificateAuthorityServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultCertificateAuthorityServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..98ef17470e1e3 100644 --- a/google/cloud/privateca/v1/internal/certificate_authority_stub.h +++ b/google/cloud/privateca/v1/internal/certificate_authority_stub.h @@ -24,7 +24,9 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include +#include #include #include #include @@ -311,6 +313,44 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -331,9 +371,18 @@ class DefaultCertificateAuthorityServiceStub std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr CreateCertificate( @@ -605,6 +654,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -621,6 +706,11 @@ class DefaultCertificateAuthorityServiceStub std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..ea0bfdc9f919b 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,10 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include +#include +#include #include #include @@ -45,9 +48,15 @@ CreateDefaultCertificateAuthorityServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::security::privateca::v1:: CertificateAuthorityService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..789e9777ba9ef 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,90 @@ 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)); +} + +StreamRange +CertificateAuthorityServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "privateca_v1::CertificateAuthorityServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +CertificateAuthorityServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "privateca_v1::CertificateAuthorityServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status CertificateAuthorityServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "privateca_v1::CertificateAuthorityServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status CertificateAuthorityServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "privateca_v1::CertificateAuthorityServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..c8f798031b3b6 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..f49dc0d4d4675 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,121 @@ 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)); +} + +StatusOr +CertificateAuthorityServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.security.privateca.v1.CertificateAuthorityService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +CertificateAuthorityServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.security.privateca.v1.CertificateAuthorityService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status CertificateAuthorityServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.security.privateca.v1.CertificateAuthorityService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status CertificateAuthorityServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.security.privateca.v1.CertificateAuthorityService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..c2479ca20be69 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..2bb7cb3aaddba 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,42 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..d1a5a189b06e7 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,50 @@ 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); +} + +StatusOr +PrivilegedAccessManagerAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +PrivilegedAccessManagerAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status PrivilegedAccessManagerAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(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..d2dfa06d860a4 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest 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..c25fe14b07614 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,116 @@ 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__); +} + +StreamRange +PrivilegedAccessManagerConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +PrivilegedAccessManagerConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status PrivilegedAccessManagerConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(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..957b820ee3cc1 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest 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..cc6ea775e3e64 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,65 @@ 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_); +} + +StatusOr +PrivilegedAccessManagerLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +PrivilegedAccessManagerLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status PrivilegedAccessManagerLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(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..9f2bac0bb432d 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest 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..833e70f44c21a 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,50 @@ 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); +} + +StatusOr +PrivilegedAccessManagerMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +PrivilegedAccessManagerMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status PrivilegedAccessManagerMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(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..2b1cfaf0bee83 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest 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..96d3ac78241b1 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,65 @@ 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; +} + +StatusOr +DefaultPrivilegedAccessManagerStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPrivilegedAccessManagerStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultPrivilegedAccessManagerStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..ffe8082e89ddd 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,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include #include @@ -147,6 +148,27 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -166,9 +188,16 @@ class DefaultPrivilegedAccessManagerStub : public PrivilegedAccessManagerStub { std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr< google::cloud::privilegedaccessmanager::v1::CheckOnboardingStatusResponse> @@ -275,6 +304,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -291,6 +340,10 @@ class DefaultPrivilegedAccessManagerStub : public PrivilegedAccessManagerStub { std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..e31a4db7aadbf 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,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,14 @@ CreateDefaultPrivilegedAccessManagerStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::privilegedaccessmanager::v1:: PrivilegedAccessManager::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..380bda1a82332 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,59 @@ 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)); +} + +StreamRange +PrivilegedAccessManagerTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "privilegedaccessmanager_v1::PrivilegedAccessManagerConnection::" + "ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +PrivilegedAccessManagerTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "privilegedaccessmanager_v1::PrivilegedAccessManagerConnection::" + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status PrivilegedAccessManagerTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "privilegedaccessmanager_v1::PrivilegedAccessManagerConnection::" + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(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..7ada0382aee46 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,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest 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..5e55b66fcb6d2 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,70 @@ 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)); +} + +StatusOr +PrivilegedAccessManagerTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +PrivilegedAccessManagerTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status PrivilegedAccessManagerTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(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..5dae464e45898 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,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest 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..2604457dd7814 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,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest 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..93bd7d318924d 100644 --- a/google/cloud/privilegedaccessmanager/v1/privileged_access_manager_client.cc +++ b/google/cloud/privilegedaccessmanager/v1/privileged_access_manager_client.cc @@ -337,6 +337,68 @@ 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); +} + +StreamRange +PrivilegedAccessManagerClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +PrivilegedAccessManagerClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +PrivilegedAccessManagerClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +PrivilegedAccessManagerClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status PrivilegedAccessManagerClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status PrivilegedAccessManagerClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(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..35438a68b379a 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,283 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest 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..aeb61504b359d 100644 --- a/google/cloud/privilegedaccessmanager/v1/privileged_access_manager_connection.cc +++ b/google/cloud/privilegedaccessmanager/v1/privileged_access_manager_connection.cc @@ -208,6 +208,39 @@ 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"); +} + +StreamRange +PrivilegedAccessManagerConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +PrivilegedAccessManagerConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status PrivilegedAccessManagerConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakePrivilegedAccessManagerConnection(Options options) { internal::CheckExpectedOptions> RevokeGrant(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest 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..2580e102c26e4 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,31 @@ 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; +} + +Idempotency PrivilegedAccessManagerConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency PrivilegedAccessManagerConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency PrivilegedAccessManagerConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..b660bb80371ca 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,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -90,6 +92,21 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest 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/pubsublite/admin_client.cc b/google/cloud/pubsublite/admin_client.cc index 31b7d7bb3daf6..e3b0cd8cc2209 100644 --- a/google/cloud/pubsublite/admin_client.cc +++ b/google/cloud/pubsublite/admin_client.cc @@ -355,6 +355,63 @@ StreamRange AdminServiceClient::ListReservationTopics( return connection_->ListReservationTopics(std::move(request)); } +StreamRange AdminServiceClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange AdminServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr AdminServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr AdminServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status AdminServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status AdminServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status AdminServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status AdminServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + future> AdminServiceClient::AsyncGetTopicPartitions(std::string const& name, Options opts) { diff --git a/google/cloud/pubsublite/admin_client.h b/google/cloud/pubsublite/admin_client.h index 49ad717599b28..a03484d139430 100644 --- a/google/cloud/pubsublite/admin_client.h +++ b/google/cloud/pubsublite/admin_client.h @@ -1285,6 +1285,286 @@ class AdminServiceClient { google::cloud::pubsublite::v1::ListReservationTopicsRequest request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + // clang-format off /// /// Returns the partition information for the requested topic. diff --git a/google/cloud/pubsublite/admin_connection.cc b/google/cloud/pubsublite/admin_connection.cc index 6dc38b098fd0a..112a8286bc8bf 100644 --- a/google/cloud/pubsublite/admin_connection.cc +++ b/google/cloud/pubsublite/admin_connection.cc @@ -173,6 +173,29 @@ StreamRange AdminServiceConnection::ListReservationTopics( StreamRange>(); } +StreamRange +AdminServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr AdminServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AdminServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AdminServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + future> AdminServiceConnection::AsyncGetTopicPartitions( google::cloud::pubsublite::v1::GetTopicPartitionsRequest const&) { diff --git a/google/cloud/pubsublite/admin_connection.h b/google/cloud/pubsublite/admin_connection.h index 225ff249a3d84..fc6f2368329b8 100644 --- a/google/cloud/pubsublite/admin_connection.h +++ b/google/cloud/pubsublite/admin_connection.h @@ -262,6 +262,18 @@ class AdminServiceConnection { virtual StreamRange ListReservationTopics( google::cloud::pubsublite::v1::ListReservationTopicsRequest request); + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); + virtual future> AsyncGetTopicPartitions( google::cloud::pubsublite::v1::GetTopicPartitionsRequest const& request); diff --git a/google/cloud/pubsublite/admin_connection_idempotency_policy.cc b/google/cloud/pubsublite/admin_connection_idempotency_policy.cc index 386f7b8e43df9..ae8e497ea53c0 100644 --- a/google/cloud/pubsublite/admin_connection_idempotency_policy.cc +++ b/google/cloud/pubsublite/admin_connection_idempotency_policy.cc @@ -129,6 +129,26 @@ Idempotency AdminServiceConnectionIdempotencyPolicy::ListReservationTopics( return Idempotency::kIdempotent; } +Idempotency AdminServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AdminServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AdminServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AdminServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultAdminServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/pubsublite/admin_connection_idempotency_policy.h b/google/cloud/pubsublite/admin_connection_idempotency_policy.h index 7daca30982223..1c1e89bdd0564 100644 --- a/google/cloud/pubsublite/admin_connection_idempotency_policy.h +++ b/google/cloud/pubsublite/admin_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -93,6 +94,18 @@ class AdminServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListReservationTopics( google::cloud::pubsublite::v1::ListReservationTopicsRequest request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/pubsublite/internal/admin_auth_decorator.cc b/google/cloud/pubsublite/internal/admin_auth_decorator.cc index 9dd5cd8a155c1..ac1cfcca47f98 100644 --- a/google/cloud/pubsublite/internal/admin_auth_decorator.cc +++ b/google/cloud/pubsublite/internal/admin_auth_decorator.cc @@ -217,6 +217,39 @@ AdminServiceAuth::ListReservationTopics( return child_->ListReservationTopics(context, options, request); } +StatusOr +AdminServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr AdminServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status AdminServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status AdminServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + future> AdminServiceAuth::AsyncGetTopicPartitions( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/pubsublite/internal/admin_auth_decorator.h b/google/cloud/pubsublite/internal/admin_auth_decorator.h index dbc976f96b4c0..9ec68596912e8 100644 --- a/google/cloud/pubsublite/internal/admin_auth_decorator.h +++ b/google/cloud/pubsublite/internal/admin_auth_decorator.h @@ -141,6 +141,22 @@ class AdminServiceAuth : public AdminServiceStub { google::cloud::pubsublite::v1::ListReservationTopicsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetTopicPartitions( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/pubsublite/internal/admin_connection_impl.cc b/google/cloud/pubsublite/internal/admin_connection_impl.cc index 75ec5d590f378..e642a3f675513 100644 --- a/google/cloud/pubsublite/internal/admin_connection_impl.cc +++ b/google/cloud/pubsublite/internal/admin_connection_impl.cc @@ -515,6 +515,79 @@ StreamRange AdminServiceConnectionImpl::ListReservationTopics( }); } +StreamRange +AdminServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +AdminServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status AdminServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status AdminServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + future> AdminServiceConnectionImpl::AsyncGetTopicPartitions( google::cloud::pubsublite::v1::GetTopicPartitionsRequest const& request) { diff --git a/google/cloud/pubsublite/internal/admin_connection_impl.h b/google/cloud/pubsublite/internal/admin_connection_impl.h index 797a18f100301..657c951058693 100644 --- a/google/cloud/pubsublite/internal/admin_connection_impl.h +++ b/google/cloud/pubsublite/internal/admin_connection_impl.h @@ -130,6 +130,18 @@ class AdminServiceConnectionImpl : public pubsublite::AdminServiceConnection { google::cloud::pubsublite::v1::ListReservationTopicsRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetTopicPartitions( google::cloud::pubsublite::v1::GetTopicPartitionsRequest const& request) diff --git a/google/cloud/pubsublite/internal/admin_logging_decorator.cc b/google/cloud/pubsublite/internal/admin_logging_decorator.cc index d825b83a51d7a..1cfe537c72f08 100644 --- a/google/cloud/pubsublite/internal/admin_logging_decorator.cc +++ b/google/cloud/pubsublite/internal/admin_logging_decorator.cc @@ -291,6 +291,51 @@ AdminServiceLogging::ListReservationTopics( context, options, request, __func__, tracing_options_); } +StatusOr +AdminServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AdminServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AdminServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AdminServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> AdminServiceLogging::AsyncGetTopicPartitions( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/pubsublite/internal/admin_logging_decorator.h b/google/cloud/pubsublite/internal/admin_logging_decorator.h index abadad9116afb..aac919b33114e 100644 --- a/google/cloud/pubsublite/internal/admin_logging_decorator.h +++ b/google/cloud/pubsublite/internal/admin_logging_decorator.h @@ -141,6 +141,22 @@ class AdminServiceLogging : public AdminServiceStub { google::cloud::pubsublite::v1::ListReservationTopicsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetTopicPartitions( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/pubsublite/internal/admin_metadata_decorator.cc b/google/cloud/pubsublite/internal/admin_metadata_decorator.cc index 38776d3313af6..c7ec2eb47bfb8 100644 --- a/google/cloud/pubsublite/internal/admin_metadata_decorator.cc +++ b/google/cloud/pubsublite/internal/admin_metadata_decorator.cc @@ -227,6 +227,39 @@ AdminServiceMetadata::ListReservationTopics( return child_->ListReservationTopics(context, options, request); } +StatusOr +AdminServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr AdminServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status AdminServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status AdminServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + future> AdminServiceMetadata::AsyncGetTopicPartitions( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/pubsublite/internal/admin_metadata_decorator.h b/google/cloud/pubsublite/internal/admin_metadata_decorator.h index a23b71427c008..c965d959351b6 100644 --- a/google/cloud/pubsublite/internal/admin_metadata_decorator.h +++ b/google/cloud/pubsublite/internal/admin_metadata_decorator.h @@ -141,6 +141,22 @@ class AdminServiceMetadata : public AdminServiceStub { google::cloud::pubsublite::v1::ListReservationTopicsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetTopicPartitions( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/pubsublite/internal/admin_stub.cc b/google/cloud/pubsublite/internal/admin_stub.cc index 30c0bfd548c1e..57de2b64b7ca7 100644 --- a/google/cloud/pubsublite/internal/admin_stub.cc +++ b/google/cloud/pubsublite/internal/admin_stub.cc @@ -278,6 +278,51 @@ DefaultAdminServiceStub::ListReservationTopics( return response; } +StatusOr +DefaultAdminServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAdminServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultAdminServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultAdminServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + future> DefaultAdminServiceStub::AsyncGetTopicPartitions( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/pubsublite/internal/admin_stub.h b/google/cloud/pubsublite/internal/admin_stub.h index 25298fec36422..f8e3aa9070a5c 100644 --- a/google/cloud/pubsublite/internal/admin_stub.h +++ b/google/cloud/pubsublite/internal/admin_stub.h @@ -144,6 +144,22 @@ class AdminServiceStub { google::cloud::pubsublite::v1::ListReservationTopicsRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetTopicPartitions( google::cloud::CompletionQueue& cq, @@ -171,9 +187,13 @@ class DefaultAdminServiceStub : public AdminServiceStub { std::unique_ptr< google::cloud::pubsublite::v1::AdminService::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr CreateTopic( grpc::ClientContext& context, Options const& options, @@ -277,6 +297,22 @@ class DefaultAdminServiceStub : public AdminServiceStub { google::cloud::pubsublite::v1::ListReservationTopicsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetTopicPartitions( google::cloud::CompletionQueue& cq, @@ -300,6 +336,8 @@ class DefaultAdminServiceStub : public AdminServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/pubsublite/internal/admin_stub_factory.cc b/google/cloud/pubsublite/internal/admin_stub_factory.cc index 00ef10ee4c8a1..e86c06a1a4aa2 100644 --- a/google/cloud/pubsublite/internal/admin_stub_factory.cc +++ b/google/cloud/pubsublite/internal/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 CreateDefaultAdminServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::pubsublite::v1::AdminService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/pubsublite/internal/admin_tracing_connection.cc b/google/cloud/pubsublite/internal/admin_tracing_connection.cc index 53f349670af57..4f134e1539bb7 100644 --- a/google/cloud/pubsublite/internal/admin_tracing_connection.cc +++ b/google/cloud/pubsublite/internal/admin_tracing_connection.cc @@ -232,6 +232,42 @@ StreamRange AdminServiceTracingConnection::ListReservationTopics( std::move(sr)); } +StreamRange +AdminServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("pubsublite::AdminServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AdminServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("pubsublite::AdminServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status AdminServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = + internal::MakeSpan("pubsublite::AdminServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status AdminServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("pubsublite::AdminServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + future> AdminServiceTracingConnection::AsyncGetTopicPartitions( google::cloud::pubsublite::v1::GetTopicPartitionsRequest const& request) { diff --git a/google/cloud/pubsublite/internal/admin_tracing_connection.h b/google/cloud/pubsublite/internal/admin_tracing_connection.h index b3e582c99ca18..a459352486601 100644 --- a/google/cloud/pubsublite/internal/admin_tracing_connection.h +++ b/google/cloud/pubsublite/internal/admin_tracing_connection.h @@ -119,6 +119,18 @@ class AdminServiceTracingConnection google::cloud::pubsublite::v1::ListReservationTopicsRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetTopicPartitions( google::cloud::pubsublite::v1::GetTopicPartitionsRequest const& request) diff --git a/google/cloud/pubsublite/internal/admin_tracing_stub.cc b/google/cloud/pubsublite/internal/admin_tracing_stub.cc index d6aacd243fafb..2c551ef2ac81a 100644 --- a/google/cloud/pubsublite/internal/admin_tracing_stub.cc +++ b/google/cloud/pubsublite/internal/admin_tracing_stub.cc @@ -275,6 +275,51 @@ AdminServiceTracingStub::ListReservationTopics( context, *span, child_->ListReservationTopics(context, options, request)); } +StatusOr +AdminServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.pubsublite.v1.AdminService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr AdminServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.pubsublite.v1.AdminService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status AdminServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.pubsublite.v1.AdminService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status AdminServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.pubsublite.v1.AdminService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + future> AdminServiceTracingStub::AsyncGetTopicPartitions( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/pubsublite/internal/admin_tracing_stub.h b/google/cloud/pubsublite/internal/admin_tracing_stub.h index 30c86d3ebc4ed..8aff23408ae07 100644 --- a/google/cloud/pubsublite/internal/admin_tracing_stub.h +++ b/google/cloud/pubsublite/internal/admin_tracing_stub.h @@ -140,6 +140,22 @@ class AdminServiceTracingStub : public AdminServiceStub { google::cloud::pubsublite::v1::ListReservationTopicsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetTopicPartitions( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/pubsublite/internal/cursor_auth_decorator.cc b/google/cloud/pubsublite/internal/cursor_auth_decorator.cc index f25c28592e838..07730996513a1 100644 --- a/google/cloud/pubsublite/internal/cursor_auth_decorator.cc +++ b/google/cloud/pubsublite/internal/cursor_auth_decorator.cc @@ -69,6 +69,39 @@ CursorServiceAuth::ListPartitionCursors( return child_->ListPartitionCursors(context, options, request); } +StatusOr +CursorServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr CursorServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status CursorServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status CursorServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsublite_internal } // namespace cloud diff --git a/google/cloud/pubsublite/internal/cursor_auth_decorator.h b/google/cloud/pubsublite/internal/cursor_auth_decorator.h index 2f8b80fef40d6..5cff54556b4a3 100644 --- a/google/cloud/pubsublite/internal/cursor_auth_decorator.h +++ b/google/cloud/pubsublite/internal/cursor_auth_decorator.h @@ -57,6 +57,22 @@ class CursorServiceAuth : public CursorServiceStub { google::cloud::pubsublite::v1::ListPartitionCursorsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/pubsublite/internal/cursor_logging_decorator.cc b/google/cloud/pubsublite/internal/cursor_logging_decorator.cc index 881d81ab74c46..4ffd50926baea 100644 --- a/google/cloud/pubsublite/internal/cursor_logging_decorator.cc +++ b/google/cloud/pubsublite/internal/cursor_logging_decorator.cc @@ -87,6 +87,51 @@ CursorServiceLogging::ListPartitionCursors( context, options, request, __func__, tracing_options_); } +StatusOr +CursorServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr CursorServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status CursorServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status CursorServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsublite_internal } // namespace cloud diff --git a/google/cloud/pubsublite/internal/cursor_logging_decorator.h b/google/cloud/pubsublite/internal/cursor_logging_decorator.h index 92219f96b8090..4ebedde431595 100644 --- a/google/cloud/pubsublite/internal/cursor_logging_decorator.h +++ b/google/cloud/pubsublite/internal/cursor_logging_decorator.h @@ -57,6 +57,22 @@ class CursorServiceLogging : public CursorServiceStub { google::cloud::pubsublite::v1::ListPartitionCursorsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/pubsublite/internal/cursor_metadata_decorator.cc b/google/cloud/pubsublite/internal/cursor_metadata_decorator.cc index 65b051cac1f96..ff59399a219c5 100644 --- a/google/cloud/pubsublite/internal/cursor_metadata_decorator.cc +++ b/google/cloud/pubsublite/internal/cursor_metadata_decorator.cc @@ -75,6 +75,39 @@ CursorServiceMetadata::ListPartitionCursors( return child_->ListPartitionCursors(context, options, request); } +StatusOr +CursorServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr CursorServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status CursorServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status CursorServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + void CursorServiceMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/pubsublite/internal/cursor_metadata_decorator.h b/google/cloud/pubsublite/internal/cursor_metadata_decorator.h index c7f4db4c7c6da..9247425a64c96 100644 --- a/google/cloud/pubsublite/internal/cursor_metadata_decorator.h +++ b/google/cloud/pubsublite/internal/cursor_metadata_decorator.h @@ -57,6 +57,22 @@ class CursorServiceMetadata : public CursorServiceStub { google::cloud::pubsublite::v1::ListPartitionCursorsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/pubsublite/internal/cursor_stub.cc b/google/cloud/pubsublite/internal/cursor_stub.cc index d2727387be756..61e5792f44a7e 100644 --- a/google/cloud/pubsublite/internal/cursor_stub.cc +++ b/google/cloud/pubsublite/internal/cursor_stub.cc @@ -71,6 +71,51 @@ DefaultCursorServiceStub::ListPartitionCursors( return response; } +StatusOr +DefaultCursorServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultCursorServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultCursorServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultCursorServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsublite_internal } // namespace cloud diff --git a/google/cloud/pubsublite/internal/cursor_stub.h b/google/cloud/pubsublite/internal/cursor_stub.h index 37f92dcecbbff..e917aeb838370 100644 --- a/google/cloud/pubsublite/internal/cursor_stub.h +++ b/google/cloud/pubsublite/internal/cursor_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -55,6 +56,22 @@ class CursorServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::pubsublite::v1::ListPartitionCursorsRequest const& request) = 0; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultCursorServiceStub : public CursorServiceStub { @@ -62,8 +79,11 @@ class DefaultCursorServiceStub : public CursorServiceStub { explicit DefaultCursorServiceStub( std::unique_ptr< google::cloud::pubsublite::v1::CursorService::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< google::cloud::pubsublite::v1::StreamingCommitCursorRequest, @@ -84,9 +104,27 @@ class DefaultCursorServiceStub : public CursorServiceStub { google::cloud::pubsublite::v1::ListPartitionCursorsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/pubsublite/internal/cursor_stub_factory.cc b/google/cloud/pubsublite/internal/cursor_stub_factory.cc index a4bc77e61ef87..e0203c6e2fb7e 100644 --- a/google/cloud/pubsublite/internal/cursor_stub_factory.cc +++ b/google/cloud/pubsublite/internal/cursor_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 CreateDefaultCursorServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::pubsublite::v1::CursorService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_stub)); if (auth->RequiresConfigureContext()) { stub = diff --git a/google/cloud/pubsublite/internal/cursor_tracing_stub.cc b/google/cloud/pubsublite/internal/cursor_tracing_stub.cc index df1741063db75..76d86726bdaee 100644 --- a/google/cloud/pubsublite/internal/cursor_tracing_stub.cc +++ b/google/cloud/pubsublite/internal/cursor_tracing_stub.cc @@ -75,6 +75,51 @@ CursorServiceTracingStub::ListPartitionCursors( context, *span, child_->ListPartitionCursors(context, options, request)); } +StatusOr +CursorServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.pubsublite.v1.CursorService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr CursorServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.pubsublite.v1.CursorService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status CursorServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.pubsublite.v1.CursorService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status CursorServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.pubsublite.v1.CursorService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeCursorServiceTracingStub( diff --git a/google/cloud/pubsublite/internal/cursor_tracing_stub.h b/google/cloud/pubsublite/internal/cursor_tracing_stub.h index 646caf9dd8e9c..bb3862e6e28bf 100644 --- a/google/cloud/pubsublite/internal/cursor_tracing_stub.h +++ b/google/cloud/pubsublite/internal/cursor_tracing_stub.h @@ -57,6 +57,22 @@ class CursorServiceTracingStub : public CursorServiceStub { google::cloud::pubsublite::v1::ListPartitionCursorsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/pubsublite/internal/partition_assignment_auth_decorator.cc b/google/cloud/pubsublite/internal/partition_assignment_auth_decorator.cc index b8490637a1055..c4e4998701735 100644 --- a/google/cloud/pubsublite/internal/partition_assignment_auth_decorator.cc +++ b/google/cloud/pubsublite/internal/partition_assignment_auth_decorator.cc @@ -51,6 +51,40 @@ PartitionAssignmentServiceAuth::AsyncAssignPartitions( std::move(context), auth_, StreamAuth::StreamFactory(std::move(call))); } +StatusOr +PartitionAssignmentServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +PartitionAssignmentServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status PartitionAssignmentServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status PartitionAssignmentServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsublite_internal } // namespace cloud diff --git a/google/cloud/pubsublite/internal/partition_assignment_auth_decorator.h b/google/cloud/pubsublite/internal/partition_assignment_auth_decorator.h index 13249ba08bc86..abdd1f1e02301 100644 --- a/google/cloud/pubsublite/internal/partition_assignment_auth_decorator.h +++ b/google/cloud/pubsublite/internal/partition_assignment_auth_decorator.h @@ -46,6 +46,22 @@ class PartitionAssignmentServiceAuth : public PartitionAssignmentServiceStub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/pubsublite/internal/partition_assignment_logging_decorator.cc b/google/cloud/pubsublite/internal/partition_assignment_logging_decorator.cc index d8bdd7ffd82b9..c5e9c077969cd 100644 --- a/google/cloud/pubsublite/internal/partition_assignment_logging_decorator.cc +++ b/google/cloud/pubsublite/internal/partition_assignment_logging_decorator.cc @@ -61,6 +61,52 @@ PartitionAssignmentServiceLogging::AsyncAssignPartitions( return stream; } +StatusOr +PartitionAssignmentServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +PartitionAssignmentServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status PartitionAssignmentServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status PartitionAssignmentServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsublite_internal } // namespace cloud diff --git a/google/cloud/pubsublite/internal/partition_assignment_logging_decorator.h b/google/cloud/pubsublite/internal/partition_assignment_logging_decorator.h index 1c1105816eb76..e05793b6f5998 100644 --- a/google/cloud/pubsublite/internal/partition_assignment_logging_decorator.h +++ b/google/cloud/pubsublite/internal/partition_assignment_logging_decorator.h @@ -47,6 +47,22 @@ class PartitionAssignmentServiceLogging std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/pubsublite/internal/partition_assignment_metadata_decorator.cc b/google/cloud/pubsublite/internal/partition_assignment_metadata_decorator.cc index 36aef702fdf07..c294407a4e0c4 100644 --- a/google/cloud/pubsublite/internal/partition_assignment_metadata_decorator.cc +++ b/google/cloud/pubsublite/internal/partition_assignment_metadata_decorator.cc @@ -56,6 +56,40 @@ PartitionAssignmentServiceMetadata::AsyncAssignPartitions( std::move(options)); } +StatusOr +PartitionAssignmentServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +PartitionAssignmentServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status PartitionAssignmentServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status PartitionAssignmentServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + void PartitionAssignmentServiceMetadata::SetMetadata( grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/pubsublite/internal/partition_assignment_metadata_decorator.h b/google/cloud/pubsublite/internal/partition_assignment_metadata_decorator.h index bb4845c27da8c..d0e109fcac5b4 100644 --- a/google/cloud/pubsublite/internal/partition_assignment_metadata_decorator.h +++ b/google/cloud/pubsublite/internal/partition_assignment_metadata_decorator.h @@ -48,6 +48,22 @@ class PartitionAssignmentServiceMetadata std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/pubsublite/internal/partition_assignment_stub.cc b/google/cloud/pubsublite/internal/partition_assignment_stub.cc index 8fe2741c95f0e..f35092434bb0b 100644 --- a/google/cloud/pubsublite/internal/partition_assignment_stub.cc +++ b/google/cloud/pubsublite/internal/partition_assignment_stub.cc @@ -47,6 +47,52 @@ DefaultPartitionAssignmentServiceStub::AsyncAssignPartitions( }); } +StatusOr +DefaultPartitionAssignmentServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPartitionAssignmentServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultPartitionAssignmentServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultPartitionAssignmentServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsublite_internal } // namespace cloud diff --git a/google/cloud/pubsublite/internal/partition_assignment_stub.h b/google/cloud/pubsublite/internal/partition_assignment_stub.h index 0ef3ceb1d009a..a5e9327a32d3a 100644 --- a/google/cloud/pubsublite/internal/partition_assignment_stub.h +++ b/google/cloud/pubsublite/internal/partition_assignment_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -43,6 +44,22 @@ class PartitionAssignmentServiceStub { AsyncAssignPartitions(google::cloud::CompletionQueue const& cq, std::shared_ptr context, google::cloud::internal::ImmutableOptions options) = 0; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultPartitionAssignmentServiceStub @@ -51,8 +68,11 @@ class DefaultPartitionAssignmentServiceStub explicit DefaultPartitionAssignmentServiceStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< google::cloud::pubsublite::v1::PartitionAssignmentRequest, @@ -62,10 +82,28 @@ class DefaultPartitionAssignmentServiceStub std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr< google::cloud::pubsublite::v1::PartitionAssignmentService::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/pubsublite/internal/partition_assignment_stub_factory.cc b/google/cloud/pubsublite/internal/partition_assignment_stub_factory.cc index db4475b9b2722..aa0daac40d0de 100644 --- a/google/cloud/pubsublite/internal/partition_assignment_stub_factory.cc +++ b/google/cloud/pubsublite/internal/partition_assignment_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 @@ CreateDefaultPartitionAssignmentServiceStub( auto service_grpc_stub = google::cloud::pubsublite::v1::PartitionAssignmentService::NewStub( channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_operations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/pubsublite/internal/partition_assignment_tracing_stub.cc b/google/cloud/pubsublite/internal/partition_assignment_tracing_stub.cc index c4ec8c94e84c6..6990d7b07d0c6 100644 --- a/google/cloud/pubsublite/internal/partition_assignment_tracing_stub.cc +++ b/google/cloud/pubsublite/internal/partition_assignment_tracing_stub.cc @@ -51,6 +51,55 @@ PartitionAssignmentServiceTracingStub::AsyncAssignPartitions( std::move(context), std::move(stream), std::move(span)); } +StatusOr +PartitionAssignmentServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.pubsublite.v1.PartitionAssignmentService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +PartitionAssignmentServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.pubsublite.v1.PartitionAssignmentService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status PartitionAssignmentServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.pubsublite.v1.PartitionAssignmentService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status PartitionAssignmentServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.pubsublite.v1.PartitionAssignmentService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/pubsublite/internal/partition_assignment_tracing_stub.h b/google/cloud/pubsublite/internal/partition_assignment_tracing_stub.h index b41243cc750a1..b2a2984c1d6fd 100644 --- a/google/cloud/pubsublite/internal/partition_assignment_tracing_stub.h +++ b/google/cloud/pubsublite/internal/partition_assignment_tracing_stub.h @@ -48,6 +48,22 @@ class PartitionAssignmentServiceTracingStub std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/pubsublite/internal/publisher_auth_decorator.cc b/google/cloud/pubsublite/internal/publisher_auth_decorator.cc index 09d10676a6d1e..676c6d6586fa1 100644 --- a/google/cloud/pubsublite/internal/publisher_auth_decorator.cc +++ b/google/cloud/pubsublite/internal/publisher_auth_decorator.cc @@ -51,6 +51,39 @@ PublisherServiceAuth::AsyncPublish( std::move(context), auth_, StreamAuth::StreamFactory(std::move(call))); } +StatusOr +PublisherServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr PublisherServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status PublisherServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status PublisherServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsublite_internal } // namespace cloud diff --git a/google/cloud/pubsublite/internal/publisher_auth_decorator.h b/google/cloud/pubsublite/internal/publisher_auth_decorator.h index 2a2aeb1f4f891..12101d22d7d5b 100644 --- a/google/cloud/pubsublite/internal/publisher_auth_decorator.h +++ b/google/cloud/pubsublite/internal/publisher_auth_decorator.h @@ -45,6 +45,22 @@ class PublisherServiceAuth : public PublisherServiceStub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/pubsublite/internal/publisher_logging_decorator.cc b/google/cloud/pubsublite/internal/publisher_logging_decorator.cc index 8bc4fa863d1eb..c87bb9e441abb 100644 --- a/google/cloud/pubsublite/internal/publisher_logging_decorator.cc +++ b/google/cloud/pubsublite/internal/publisher_logging_decorator.cc @@ -61,6 +61,51 @@ PublisherServiceLogging::AsyncPublish( return stream; } +StatusOr +PublisherServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr PublisherServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status PublisherServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status PublisherServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsublite_internal } // namespace cloud diff --git a/google/cloud/pubsublite/internal/publisher_logging_decorator.h b/google/cloud/pubsublite/internal/publisher_logging_decorator.h index e5fa63bc8efc8..4b7f074871f28 100644 --- a/google/cloud/pubsublite/internal/publisher_logging_decorator.h +++ b/google/cloud/pubsublite/internal/publisher_logging_decorator.h @@ -45,6 +45,22 @@ class PublisherServiceLogging : public PublisherServiceStub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/pubsublite/internal/publisher_metadata_decorator.cc b/google/cloud/pubsublite/internal/publisher_metadata_decorator.cc index 877dfa6b359ed..90ff8c424f1d8 100644 --- a/google/cloud/pubsublite/internal/publisher_metadata_decorator.cc +++ b/google/cloud/pubsublite/internal/publisher_metadata_decorator.cc @@ -55,6 +55,39 @@ PublisherServiceMetadata::AsyncPublish( return child_->AsyncPublish(cq, std::move(context), std::move(options)); } +StatusOr +PublisherServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr PublisherServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status PublisherServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status PublisherServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + void PublisherServiceMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/pubsublite/internal/publisher_metadata_decorator.h b/google/cloud/pubsublite/internal/publisher_metadata_decorator.h index ebaeb3273fa7b..9880f423289ce 100644 --- a/google/cloud/pubsublite/internal/publisher_metadata_decorator.h +++ b/google/cloud/pubsublite/internal/publisher_metadata_decorator.h @@ -46,6 +46,22 @@ class PublisherServiceMetadata : public PublisherServiceStub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/pubsublite/internal/publisher_stub.cc b/google/cloud/pubsublite/internal/publisher_stub.cc index 5b6d78dd5efe1..3c4b92a94286c 100644 --- a/google/cloud/pubsublite/internal/publisher_stub.cc +++ b/google/cloud/pubsublite/internal/publisher_stub.cc @@ -47,6 +47,52 @@ DefaultPublisherServiceStub::AsyncPublish( }); } +StatusOr +DefaultPublisherServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPublisherServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultPublisherServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultPublisherServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsublite_internal } // namespace cloud diff --git a/google/cloud/pubsublite/internal/publisher_stub.h b/google/cloud/pubsublite/internal/publisher_stub.h index d8b24e4c2318b..a97b85cf74ef6 100644 --- a/google/cloud/pubsublite/internal/publisher_stub.h +++ b/google/cloud/pubsublite/internal/publisher_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -43,6 +44,22 @@ class PublisherServiceStub { AsyncPublish(google::cloud::CompletionQueue const& cq, std::shared_ptr context, google::cloud::internal::ImmutableOptions options) = 0; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultPublisherServiceStub : public PublisherServiceStub { @@ -50,8 +67,11 @@ class DefaultPublisherServiceStub : public PublisherServiceStub { explicit DefaultPublisherServiceStub( std::unique_ptr< google::cloud::pubsublite::v1::PublisherService::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< google::cloud::pubsublite::v1::PublishRequest, @@ -60,10 +80,28 @@ class DefaultPublisherServiceStub : public PublisherServiceStub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr< google::cloud::pubsublite::v1::PublisherService::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/pubsublite/internal/publisher_stub_factory.cc b/google/cloud/pubsublite/internal/publisher_stub_factory.cc index 9472908125723..8b3b80bcac587 100644 --- a/google/cloud/pubsublite/internal/publisher_stub_factory.cc +++ b/google/cloud/pubsublite/internal/publisher_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 CreateDefaultPublisherServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::pubsublite::v1::PublisherService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_operations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/pubsublite/internal/publisher_tracing_stub.cc b/google/cloud/pubsublite/internal/publisher_tracing_stub.cc index 0ba367e685dbd..808ccb1705e24 100644 --- a/google/cloud/pubsublite/internal/publisher_tracing_stub.cc +++ b/google/cloud/pubsublite/internal/publisher_tracing_stub.cc @@ -50,6 +50,52 @@ PublisherServiceTracingStub::AsyncPublish( std::move(context), std::move(stream), std::move(span)); } +StatusOr +PublisherServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.pubsublite.v1.PublisherService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +PublisherServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.pubsublite.v1.PublisherService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status PublisherServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.pubsublite.v1.PublisherService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status PublisherServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.pubsublite.v1.PublisherService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakePublisherServiceTracingStub( diff --git a/google/cloud/pubsublite/internal/publisher_tracing_stub.h b/google/cloud/pubsublite/internal/publisher_tracing_stub.h index df2912a470fcf..3785fc968a446 100644 --- a/google/cloud/pubsublite/internal/publisher_tracing_stub.h +++ b/google/cloud/pubsublite/internal/publisher_tracing_stub.h @@ -46,6 +46,22 @@ class PublisherServiceTracingStub : public PublisherServiceStub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/pubsublite/internal/subscriber_auth_decorator.cc b/google/cloud/pubsublite/internal/subscriber_auth_decorator.cc index e512708d8c84b..52eba69d9ce42 100644 --- a/google/cloud/pubsublite/internal/subscriber_auth_decorator.cc +++ b/google/cloud/pubsublite/internal/subscriber_auth_decorator.cc @@ -51,6 +51,39 @@ SubscriberServiceAuth::AsyncSubscribe( std::move(context), auth_, StreamAuth::StreamFactory(std::move(call))); } +StatusOr +SubscriberServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr SubscriberServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status SubscriberServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status SubscriberServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsublite_internal } // namespace cloud diff --git a/google/cloud/pubsublite/internal/subscriber_auth_decorator.h b/google/cloud/pubsublite/internal/subscriber_auth_decorator.h index 164be9f501e36..2a1d1183bce3f 100644 --- a/google/cloud/pubsublite/internal/subscriber_auth_decorator.h +++ b/google/cloud/pubsublite/internal/subscriber_auth_decorator.h @@ -45,6 +45,22 @@ class SubscriberServiceAuth : public SubscriberServiceStub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/pubsublite/internal/subscriber_logging_decorator.cc b/google/cloud/pubsublite/internal/subscriber_logging_decorator.cc index 6696cc20664f1..136675dfd4695 100644 --- a/google/cloud/pubsublite/internal/subscriber_logging_decorator.cc +++ b/google/cloud/pubsublite/internal/subscriber_logging_decorator.cc @@ -61,6 +61,51 @@ SubscriberServiceLogging::AsyncSubscribe( return stream; } +StatusOr +SubscriberServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr SubscriberServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status SubscriberServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status SubscriberServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsublite_internal } // namespace cloud diff --git a/google/cloud/pubsublite/internal/subscriber_logging_decorator.h b/google/cloud/pubsublite/internal/subscriber_logging_decorator.h index 75837dee5b4ad..2c866c3959a1e 100644 --- a/google/cloud/pubsublite/internal/subscriber_logging_decorator.h +++ b/google/cloud/pubsublite/internal/subscriber_logging_decorator.h @@ -45,6 +45,22 @@ class SubscriberServiceLogging : public SubscriberServiceStub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/pubsublite/internal/subscriber_metadata_decorator.cc b/google/cloud/pubsublite/internal/subscriber_metadata_decorator.cc index e8aebe728084a..b7638ba07bb4b 100644 --- a/google/cloud/pubsublite/internal/subscriber_metadata_decorator.cc +++ b/google/cloud/pubsublite/internal/subscriber_metadata_decorator.cc @@ -55,6 +55,40 @@ SubscriberServiceMetadata::AsyncSubscribe( return child_->AsyncSubscribe(cq, std::move(context), std::move(options)); } +StatusOr +SubscriberServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +SubscriberServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status SubscriberServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status SubscriberServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + void SubscriberServiceMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/pubsublite/internal/subscriber_metadata_decorator.h b/google/cloud/pubsublite/internal/subscriber_metadata_decorator.h index 05d19735a9578..8bcfd49d23468 100644 --- a/google/cloud/pubsublite/internal/subscriber_metadata_decorator.h +++ b/google/cloud/pubsublite/internal/subscriber_metadata_decorator.h @@ -46,6 +46,22 @@ class SubscriberServiceMetadata : public SubscriberServiceStub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/pubsublite/internal/subscriber_stub.cc b/google/cloud/pubsublite/internal/subscriber_stub.cc index 248dfe5e4fa3e..685c133b0deb9 100644 --- a/google/cloud/pubsublite/internal/subscriber_stub.cc +++ b/google/cloud/pubsublite/internal/subscriber_stub.cc @@ -47,6 +47,52 @@ DefaultSubscriberServiceStub::AsyncSubscribe( }); } +StatusOr +DefaultSubscriberServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultSubscriberServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultSubscriberServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultSubscriberServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsublite_internal } // namespace cloud diff --git a/google/cloud/pubsublite/internal/subscriber_stub.h b/google/cloud/pubsublite/internal/subscriber_stub.h index a9235f2f419c0..eda8cb45b74e9 100644 --- a/google/cloud/pubsublite/internal/subscriber_stub.h +++ b/google/cloud/pubsublite/internal/subscriber_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -43,6 +44,22 @@ class SubscriberServiceStub { AsyncSubscribe(google::cloud::CompletionQueue const& cq, std::shared_ptr context, google::cloud::internal::ImmutableOptions options) = 0; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultSubscriberServiceStub : public SubscriberServiceStub { @@ -50,8 +67,11 @@ class DefaultSubscriberServiceStub : public SubscriberServiceStub { explicit DefaultSubscriberServiceStub( std::unique_ptr< google::cloud::pubsublite::v1::SubscriberService::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< google::cloud::pubsublite::v1::SubscribeRequest, @@ -60,10 +80,28 @@ class DefaultSubscriberServiceStub : public SubscriberServiceStub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr< google::cloud::pubsublite::v1::SubscriberService::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/pubsublite/internal/subscriber_stub_factory.cc b/google/cloud/pubsublite/internal/subscriber_stub_factory.cc index 7a5ca6461ebd7..bfc79126ca7f6 100644 --- a/google/cloud/pubsublite/internal/subscriber_stub_factory.cc +++ b/google/cloud/pubsublite/internal/subscriber_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 CreateDefaultSubscriberServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::pubsublite::v1::SubscriberService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_operations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/pubsublite/internal/subscriber_tracing_stub.cc b/google/cloud/pubsublite/internal/subscriber_tracing_stub.cc index 37dc52b055222..3d4822a3ea8c7 100644 --- a/google/cloud/pubsublite/internal/subscriber_tracing_stub.cc +++ b/google/cloud/pubsublite/internal/subscriber_tracing_stub.cc @@ -50,6 +50,52 @@ SubscriberServiceTracingStub::AsyncSubscribe( std::move(context), std::move(stream), std::move(span)); } +StatusOr +SubscriberServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.pubsublite.v1.SubscriberService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +SubscriberServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.pubsublite.v1.SubscriberService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status SubscriberServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.pubsublite.v1.SubscriberService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status SubscriberServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.pubsublite.v1.SubscriberService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeSubscriberServiceTracingStub( diff --git a/google/cloud/pubsublite/internal/subscriber_tracing_stub.h b/google/cloud/pubsublite/internal/subscriber_tracing_stub.h index a2fb2c61d721f..3f9b7c90fb203 100644 --- a/google/cloud/pubsublite/internal/subscriber_tracing_stub.h +++ b/google/cloud/pubsublite/internal/subscriber_tracing_stub.h @@ -46,6 +46,22 @@ class SubscriberServiceTracingStub : public SubscriberServiceStub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/pubsublite/internal/topic_stats_auth_decorator.cc b/google/cloud/pubsublite/internal/topic_stats_auth_decorator.cc index f51a805d23892..84176ab705675 100644 --- a/google/cloud/pubsublite/internal/topic_stats_auth_decorator.cc +++ b/google/cloud/pubsublite/internal/topic_stats_auth_decorator.cc @@ -58,6 +58,39 @@ TopicStatsServiceAuth::ComputeTimeCursor( return child_->ComputeTimeCursor(context, options, request); } +StatusOr +TopicStatsServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr TopicStatsServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status TopicStatsServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status TopicStatsServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsublite_internal } // namespace cloud diff --git a/google/cloud/pubsublite/internal/topic_stats_auth_decorator.h b/google/cloud/pubsublite/internal/topic_stats_auth_decorator.h index 34f041cac6a86..8eb92fdfce90a 100644 --- a/google/cloud/pubsublite/internal/topic_stats_auth_decorator.h +++ b/google/cloud/pubsublite/internal/topic_stats_auth_decorator.h @@ -56,6 +56,22 @@ class TopicStatsServiceAuth : public TopicStatsServiceStub { google::cloud::pubsublite::v1::ComputeTimeCursorRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/pubsublite/internal/topic_stats_connection_impl.cc b/google/cloud/pubsublite/internal/topic_stats_connection_impl.cc index 614c044a70a19..1e0ffd2c0d952 100644 --- a/google/cloud/pubsublite/internal/topic_stats_connection_impl.cc +++ b/google/cloud/pubsublite/internal/topic_stats_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 @@ -104,6 +105,79 @@ TopicStatsServiceConnectionImpl::ComputeTimeCursor( *current, request, __func__); } +StreamRange +TopicStatsServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +TopicStatsServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status TopicStatsServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status TopicStatsServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsublite_internal } // namespace cloud diff --git a/google/cloud/pubsublite/internal/topic_stats_connection_impl.h b/google/cloud/pubsublite/internal/topic_stats_connection_impl.h index 9be8fc8990bba..cabee1accf2fc 100644 --- a/google/cloud/pubsublite/internal/topic_stats_connection_impl.h +++ b/google/cloud/pubsublite/internal/topic_stats_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 @@ -63,6 +64,18 @@ class TopicStatsServiceConnectionImpl google::cloud::pubsublite::v1::ComputeTimeCursorRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/pubsublite/internal/topic_stats_logging_decorator.cc b/google/cloud/pubsublite/internal/topic_stats_logging_decorator.cc index b03b69331e160..8c5ffffaa7897 100644 --- a/google/cloud/pubsublite/internal/topic_stats_logging_decorator.cc +++ b/google/cloud/pubsublite/internal/topic_stats_logging_decorator.cc @@ -74,6 +74,51 @@ TopicStatsServiceLogging::ComputeTimeCursor( context, options, request, __func__, tracing_options_); } +StatusOr +TopicStatsServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr TopicStatsServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status TopicStatsServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status TopicStatsServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsublite_internal } // namespace cloud diff --git a/google/cloud/pubsublite/internal/topic_stats_logging_decorator.h b/google/cloud/pubsublite/internal/topic_stats_logging_decorator.h index 351b184dc2b77..a435c7d5620c8 100644 --- a/google/cloud/pubsublite/internal/topic_stats_logging_decorator.h +++ b/google/cloud/pubsublite/internal/topic_stats_logging_decorator.h @@ -56,6 +56,22 @@ class TopicStatsServiceLogging : public TopicStatsServiceStub { google::cloud::pubsublite::v1::ComputeTimeCursorRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/pubsublite/internal/topic_stats_metadata_decorator.cc b/google/cloud/pubsublite/internal/topic_stats_metadata_decorator.cc index a83a471e75445..d5888c35d0966 100644 --- a/google/cloud/pubsublite/internal/topic_stats_metadata_decorator.cc +++ b/google/cloud/pubsublite/internal/topic_stats_metadata_decorator.cc @@ -71,6 +71,40 @@ TopicStatsServiceMetadata::ComputeTimeCursor( return child_->ComputeTimeCursor(context, options, request); } +StatusOr +TopicStatsServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +TopicStatsServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status TopicStatsServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status TopicStatsServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + void TopicStatsServiceMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/pubsublite/internal/topic_stats_metadata_decorator.h b/google/cloud/pubsublite/internal/topic_stats_metadata_decorator.h index 8d69b73ac9653..c552e0529dda3 100644 --- a/google/cloud/pubsublite/internal/topic_stats_metadata_decorator.h +++ b/google/cloud/pubsublite/internal/topic_stats_metadata_decorator.h @@ -57,6 +57,22 @@ class TopicStatsServiceMetadata : public TopicStatsServiceStub { google::cloud::pubsublite::v1::ComputeTimeCursorRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/pubsublite/internal/topic_stats_stub.cc b/google/cloud/pubsublite/internal/topic_stats_stub.cc index 51b679721b45d..35926bb67f968 100644 --- a/google/cloud/pubsublite/internal/topic_stats_stub.cc +++ b/google/cloud/pubsublite/internal/topic_stats_stub.cc @@ -66,6 +66,52 @@ DefaultTopicStatsServiceStub::ComputeTimeCursor( return response; } +StatusOr +DefaultTopicStatsServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultTopicStatsServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultTopicStatsServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultTopicStatsServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsublite_internal } // namespace cloud diff --git a/google/cloud/pubsublite/internal/topic_stats_stub.h b/google/cloud/pubsublite/internal/topic_stats_stub.h index 4d7803b4ce7c9..0e396f2685937 100644 --- a/google/cloud/pubsublite/internal/topic_stats_stub.h +++ b/google/cloud/pubsublite/internal/topic_stats_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -52,6 +53,22 @@ class TopicStatsServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::pubsublite::v1::ComputeTimeCursorRequest const& request) = 0; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultTopicStatsServiceStub : public TopicStatsServiceStub { @@ -59,8 +76,11 @@ class DefaultTopicStatsServiceStub : public TopicStatsServiceStub { explicit DefaultTopicStatsServiceStub( std::unique_ptr< google::cloud::pubsublite::v1::TopicStatsService::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr ComputeMessageStats( @@ -80,10 +100,28 @@ class DefaultTopicStatsServiceStub : public TopicStatsServiceStub { google::cloud::pubsublite::v1::ComputeTimeCursorRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr< google::cloud::pubsublite::v1::TopicStatsService::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/pubsublite/internal/topic_stats_stub_factory.cc b/google/cloud/pubsublite/internal/topic_stats_stub_factory.cc index 536c1399a6b57..e2da9d34ed65c 100644 --- a/google/cloud/pubsublite/internal/topic_stats_stub_factory.cc +++ b/google/cloud/pubsublite/internal/topic_stats_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 CreateDefaultTopicStatsServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::pubsublite::v1::TopicStatsService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_operations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/pubsublite/internal/topic_stats_tracing_connection.cc b/google/cloud/pubsublite/internal/topic_stats_tracing_connection.cc index e905ca8691f6a..4bd64200e74df 100644 --- a/google/cloud/pubsublite/internal/topic_stats_tracing_connection.cc +++ b/google/cloud/pubsublite/internal/topic_stats_tracing_connection.cc @@ -18,6 +18,7 @@ #include "google/cloud/pubsublite/internal/topic_stats_tracing_connection.h" #include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" #include #include @@ -59,6 +60,42 @@ TopicStatsServiceTracingConnection::ComputeTimeCursor( return internal::EndSpan(*span, child_->ComputeTimeCursor(request)); } +StreamRange +TopicStatsServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "pubsublite::TopicStatsServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +TopicStatsServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "pubsublite::TopicStatsServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status TopicStatsServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "pubsublite::TopicStatsServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status TopicStatsServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "pubsublite::TopicStatsServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/pubsublite/internal/topic_stats_tracing_connection.h b/google/cloud/pubsublite/internal/topic_stats_tracing_connection.h index b4d2348c93757..e204b8f78c2ca 100644 --- a/google/cloud/pubsublite/internal/topic_stats_tracing_connection.h +++ b/google/cloud/pubsublite/internal/topic_stats_tracing_connection.h @@ -55,6 +55,18 @@ class TopicStatsServiceTracingConnection google::cloud::pubsublite::v1::ComputeTimeCursorRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/pubsublite/internal/topic_stats_tracing_stub.cc b/google/cloud/pubsublite/internal/topic_stats_tracing_stub.cc index 71248b94f1b56..1d626905e8dd5 100644 --- a/google/cloud/pubsublite/internal/topic_stats_tracing_stub.cc +++ b/google/cloud/pubsublite/internal/topic_stats_tracing_stub.cc @@ -68,6 +68,52 @@ TopicStatsServiceTracingStub::ComputeTimeCursor( context, *span, child_->ComputeTimeCursor(context, options, request)); } +StatusOr +TopicStatsServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.pubsublite.v1.TopicStatsService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +TopicStatsServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.pubsublite.v1.TopicStatsService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status TopicStatsServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.pubsublite.v1.TopicStatsService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status TopicStatsServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.pubsublite.v1.TopicStatsService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeTopicStatsServiceTracingStub( diff --git a/google/cloud/pubsublite/internal/topic_stats_tracing_stub.h b/google/cloud/pubsublite/internal/topic_stats_tracing_stub.h index a7b7159abb77e..cb3ddda33bbea 100644 --- a/google/cloud/pubsublite/internal/topic_stats_tracing_stub.h +++ b/google/cloud/pubsublite/internal/topic_stats_tracing_stub.h @@ -57,6 +57,22 @@ class TopicStatsServiceTracingStub : public TopicStatsServiceStub { google::cloud::pubsublite::v1::ComputeTimeCursorRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/pubsublite/mocks/mock_admin_connection.h b/google/cloud/pubsublite/mocks/mock_admin_connection.h index 5fe5f210d47ea..15001dc8c50a1 100644 --- a/google/cloud/pubsublite/mocks/mock_admin_connection.h +++ b/google/cloud/pubsublite/mocks/mock_admin_connection.h @@ -175,6 +175,21 @@ class MockAdminServiceConnection : public pubsublite::AdminServiceConnection { (google::cloud::pubsublite::v1::ListReservationTopicsRequest request), (override)); + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); + MOCK_METHOD( future>, AsyncGetTopicPartitions, diff --git a/google/cloud/pubsublite/mocks/mock_topic_stats_connection.h b/google/cloud/pubsublite/mocks/mock_topic_stats_connection.h index 4920825272f63..d70e002654162 100644 --- a/google/cloud/pubsublite/mocks/mock_topic_stats_connection.h +++ b/google/cloud/pubsublite/mocks/mock_topic_stats_connection.h @@ -65,6 +65,21 @@ class MockTopicStatsServiceConnection ComputeTimeCursor, (google::cloud::pubsublite::v1::ComputeTimeCursorRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/pubsublite/topic_stats_client.cc b/google/cloud/pubsublite/topic_stats_client.cc index f59d26b26a7c4..e2b2dfc3e6440 100644 --- a/google/cloud/pubsublite/topic_stats_client.cc +++ b/google/cloud/pubsublite/topic_stats_client.cc @@ -56,6 +56,66 @@ TopicStatsServiceClient::ComputeTimeCursor( return connection_->ComputeTimeCursor(request); } +StreamRange +TopicStatsServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +TopicStatsServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr TopicStatsServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr TopicStatsServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status TopicStatsServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status TopicStatsServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status TopicStatsServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status TopicStatsServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsublite } // namespace cloud diff --git a/google/cloud/pubsublite/topic_stats_client.h b/google/cloud/pubsublite/topic_stats_client.h index 1bac47c45ef8c..cb281d46b247c 100644 --- a/google/cloud/pubsublite/topic_stats_client.h +++ b/google/cloud/pubsublite/topic_stats_client.h @@ -189,6 +189,286 @@ class TopicStatsServiceClient { google::cloud::pubsublite::v1::ComputeTimeCursorRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/pubsublite/topic_stats_connection.cc b/google/cloud/pubsublite/topic_stats_connection.cc index 822175eed2fa2..bf71b9ca43914 100644 --- a/google/cloud/pubsublite/topic_stats_connection.cc +++ b/google/cloud/pubsublite/topic_stats_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,30 @@ TopicStatsServiceConnection::ComputeTimeCursor( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +TopicStatsServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +TopicStatsServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status TopicStatsServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status TopicStatsServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeTopicStatsServiceConnection( Options options) { internal::CheckExpectedOptions #include @@ -195,6 +196,18 @@ class TopicStatsServiceConnection { virtual StatusOr ComputeTimeCursor( google::cloud::pubsublite::v1::ComputeTimeCursorRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/pubsublite/topic_stats_connection_idempotency_policy.cc b/google/cloud/pubsublite/topic_stats_connection_idempotency_policy.cc index 767e004a97714..9a85f8a4a8ec5 100644 --- a/google/cloud/pubsublite/topic_stats_connection_idempotency_policy.cc +++ b/google/cloud/pubsublite/topic_stats_connection_idempotency_policy.cc @@ -49,6 +49,26 @@ Idempotency TopicStatsServiceConnectionIdempotencyPolicy::ComputeTimeCursor( return Idempotency::kNonIdempotent; } +Idempotency TopicStatsServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency TopicStatsServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency TopicStatsServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency TopicStatsServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultTopicStatsServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/pubsublite/topic_stats_connection_idempotency_policy.h b/google/cloud/pubsublite/topic_stats_connection_idempotency_policy.h index ce13838b8d590..cf2a6c85c662d 100644 --- a/google/cloud/pubsublite/topic_stats_connection_idempotency_policy.h +++ b/google/cloud/pubsublite/topic_stats_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,18 @@ class TopicStatsServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ComputeTimeCursor( google::cloud::pubsublite::v1::ComputeTimeCursorRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr 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..4f42d6be52276 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,58 @@ 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); +} + +StatusOr +RapidMigrationAssessmentAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +RapidMigrationAssessmentAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status RapidMigrationAssessmentAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status RapidMigrationAssessmentAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..7f21f099e3aef 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..26f3e42626113 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,129 @@ 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__); +} + +StreamRange +RapidMigrationAssessmentConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +RapidMigrationAssessmentConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status RapidMigrationAssessmentConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status RapidMigrationAssessmentConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..93b4aac53ccfa 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..79dd5d13f9f6a 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,76 @@ 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_); +} + +StatusOr +RapidMigrationAssessmentLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +RapidMigrationAssessmentLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status RapidMigrationAssessmentLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status RapidMigrationAssessmentLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..2c0fc153d3fc9 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..b80e56b1a0561 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,58 @@ 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); +} + +StatusOr +RapidMigrationAssessmentMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +RapidMigrationAssessmentMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status RapidMigrationAssessmentMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status RapidMigrationAssessmentMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..a03d74f2e46c4 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..b6de00fedd471 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,76 @@ 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; +} + +StatusOr +DefaultRapidMigrationAssessmentStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultRapidMigrationAssessmentStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultRapidMigrationAssessmentStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultRapidMigrationAssessmentStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..2cb649887f0be 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,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include #include @@ -142,6 +143,31 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -162,9 +188,16 @@ class DefaultRapidMigrationAssessmentStub std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateCollector( google::cloud::CompletionQueue& cq, @@ -267,6 +300,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -283,6 +340,10 @@ class DefaultRapidMigrationAssessmentStub std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..fcfe3b24cd5e9 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,7 +29,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,14 @@ CreateDefaultRapidMigrationAssessmentStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::rapidmigrationassessment::v1:: RapidMigrationAssessment::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..c440ff1686cfd 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,68 @@ 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)); +} + +StreamRange +RapidMigrationAssessmentTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "rapidmigrationassessment_v1::RapidMigrationAssessmentConnection::" + "ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +RapidMigrationAssessmentTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "rapidmigrationassessment_v1::RapidMigrationAssessmentConnection::" + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status RapidMigrationAssessmentTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "rapidmigrationassessment_v1::RapidMigrationAssessmentConnection::" + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status RapidMigrationAssessmentTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "rapidmigrationassessment_v1::RapidMigrationAssessmentConnection::" + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..d8814e5fc6b91 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..6ff09400c296d 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,82 @@ 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)); +} + +StatusOr +RapidMigrationAssessmentTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +RapidMigrationAssessmentTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status RapidMigrationAssessmentTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status RapidMigrationAssessmentTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..299040b0b5459 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..aaaf275b02d60 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,29 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..ef20fc06d7d81 100644 --- a/google/cloud/rapidmigrationassessment/v1/rapid_migration_assessment_client.cc +++ b/google/cloud/rapidmigrationassessment/v1/rapid_migration_assessment_client.cc @@ -418,6 +418,82 @@ 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); +} + +StreamRange +RapidMigrationAssessmentClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +RapidMigrationAssessmentClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +RapidMigrationAssessmentClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +RapidMigrationAssessmentClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status RapidMigrationAssessmentClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status RapidMigrationAssessmentClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status RapidMigrationAssessmentClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status RapidMigrationAssessmentClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..0e4372963e94b 100644 --- a/google/cloud/rapidmigrationassessment/v1/rapid_migration_assessment_client.h +++ b/google/cloud/rapidmigrationassessment/v1/rapid_migration_assessment_client.h @@ -1120,6 +1120,356 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..da229cc1d43b3 100644 --- a/google/cloud/rapidmigrationassessment/v1/rapid_migration_assessment_connection.cc +++ b/google/cloud/rapidmigrationassessment/v1/rapid_migration_assessment_connection.cc @@ -234,6 +234,44 @@ 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"); +} + +StreamRange +RapidMigrationAssessmentConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +RapidMigrationAssessmentConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status RapidMigrationAssessmentConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status RapidMigrationAssessmentConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeRapidMigrationAssessmentConnection(Options options) { internal::CheckExpectedOptions> PauseCollector(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..931677eb9d911 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,38 @@ 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; +} + +Idempotency RapidMigrationAssessmentConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency RapidMigrationAssessmentConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +RapidMigrationAssessmentConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency +RapidMigrationAssessmentConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..72ab20f636621 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,7 +22,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -77,6 +79,24 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..bceb2a7e62664 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,80 @@ 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); +} + +StreamRange +CloudRedisClusterClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +CloudRedisClusterClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr CloudRedisClusterClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr CloudRedisClusterClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status CloudRedisClusterClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status CloudRedisClusterClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status CloudRedisClusterClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status CloudRedisClusterClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..928451ffdc28c 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,356 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..be3a4f1306df2 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,44 @@ 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"); +} + +StreamRange +CloudRedisClusterConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +CloudRedisClusterConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status CloudRedisClusterConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status CloudRedisClusterConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeCloudRedisClusterConnection( Options options) { internal::CheckExpectedOptions ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..c20ebcb18dbfb 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,36 @@ 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; +} + +Idempotency CloudRedisClusterConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency CloudRedisClusterConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency CloudRedisClusterConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency CloudRedisClusterConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..ae3984d191256 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,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -55,6 +57,24 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..ad243dc7ff46c 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,56 @@ 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); +} + +StatusOr +CloudRedisClusterAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr CloudRedisClusterAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status CloudRedisClusterAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status CloudRedisClusterAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..91c2398a9a161 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..9cf50c90faa62 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,127 @@ 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__); +} + +StreamRange +CloudRedisClusterConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +CloudRedisClusterConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status CloudRedisClusterConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status CloudRedisClusterConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..856ab29db5c58 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..7afb41ade72aa 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,75 @@ 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_); +} + +StatusOr +CloudRedisClusterLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr CloudRedisClusterLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status CloudRedisClusterLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status CloudRedisClusterLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..cf42eaafa6e1d 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..3784c1df688a4 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,58 @@ 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); +} + +StatusOr +CloudRedisClusterMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +CloudRedisClusterMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status CloudRedisClusterMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status CloudRedisClusterMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..ee07a7d850436 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..baa06b7d22bb8 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,76 @@ 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; +} + +StatusOr +DefaultCloudRedisClusterStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultCloudRedisClusterStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultCloudRedisClusterStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultCloudRedisClusterStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..4a81adeaa24fd 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,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include #include @@ -89,6 +90,31 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -108,9 +134,16 @@ class DefaultCloudRedisClusterStub : public CloudRedisClusterStub { std::unique_ptr< google::cloud::redis::cluster::v1::CloudRedisCluster::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListClusters(grpc::ClientContext& context, Options const& options, @@ -164,6 +197,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -180,6 +237,10 @@ class DefaultCloudRedisClusterStub : public CloudRedisClusterStub { std::unique_ptr< google::cloud::redis::cluster::v1::CloudRedisCluster::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..09fc45278f378 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,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,14 @@ std::shared_ptr CreateDefaultCloudRedisClusterStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::redis::cluster::v1::CloudRedisCluster::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..85e50f6bf12e2 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,62 @@ 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)); +} + +StreamRange +CloudRedisClusterTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "redis_cluster_v1::CloudRedisClusterConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +CloudRedisClusterTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "redis_cluster_v1::CloudRedisClusterConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status CloudRedisClusterTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "redis_cluster_v1::CloudRedisClusterConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status CloudRedisClusterTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "redis_cluster_v1::CloudRedisClusterConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..62ddcf053b960 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..c92a209b6d9c8 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,76 @@ 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)); +} + +StatusOr +CloudRedisClusterTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.redis.cluster.v1.CloudRedisCluster", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +CloudRedisClusterTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.redis.cluster.v1.CloudRedisCluster", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status CloudRedisClusterTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.redis.cluster.v1.CloudRedisCluster", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status CloudRedisClusterTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.redis.cluster.v1.CloudRedisCluster", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..04538c2263bfc 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..78b14eb5700ed 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,29 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..2f02409ee6469 100644 --- a/google/cloud/redis/v1/cloud_redis_client.cc +++ b/google/cloud/redis/v1/cloud_redis_client.cc @@ -431,6 +431,75 @@ 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); +} + +StreamRange CloudRedisClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange CloudRedisClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr CloudRedisClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr CloudRedisClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status CloudRedisClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status CloudRedisClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status CloudRedisClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status CloudRedisClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..95ef969434c3e 100644 --- a/google/cloud/redis/v1/cloud_redis_client.h +++ b/google/cloud/redis/v1/cloud_redis_client.h @@ -1341,6 +1341,356 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..27dc2a975a041 100644 --- a/google/cloud/redis/v1/cloud_redis_connection.cc +++ b/google/cloud/redis/v1/cloud_redis_connection.cc @@ -227,6 +227,42 @@ 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"); +} + +StreamRange +CloudRedisConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr CloudRedisConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status CloudRedisConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status CloudRedisConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeCloudRedisConnection( Options options) { internal::CheckExpectedOptions> RescheduleMaintenance(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..34b16cff62bef 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,36 @@ 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; +} + +Idempotency CloudRedisConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency CloudRedisConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency CloudRedisConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency CloudRedisConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..3ac71638a3160 100644 --- a/google/cloud/redis/v1/cloud_redis_connection_idempotency_policy.h +++ b/google/cloud/redis/v1/cloud_redis_connection_idempotency_policy.h @@ -21,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -68,6 +70,24 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..6602bd179613d 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,56 @@ 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); +} + +StatusOr +CloudRedisAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr CloudRedisAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status CloudRedisAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status CloudRedisAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..5c43a28fee550 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..42aeb984c8499 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,126 @@ 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__); +} + +StreamRange +CloudRedisConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr CloudRedisConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status CloudRedisConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status CloudRedisConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..9e56f167972e9 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..191af4d971bf6 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,74 @@ 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_); +} + +StatusOr +CloudRedisLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr CloudRedisLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status CloudRedisLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status CloudRedisLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..a7aac7138cd17 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..2a3ac2c4778c4 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,56 @@ 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); +} + +StatusOr +CloudRedisMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr CloudRedisMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status CloudRedisMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status CloudRedisMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..7efd524661b56 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..13d74612c0cae 100644 --- a/google/cloud/redis/v1/internal/cloud_redis_stub.cc +++ b/google/cloud/redis/v1/internal/cloud_redis_stub.cc @@ -301,6 +301,74 @@ 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; +} + +StatusOr +DefaultCloudRedisStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultCloudRedisStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultCloudRedisStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultCloudRedisStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..b2193dd08b097 100644 --- a/google/cloud/redis/v1/internal/cloud_redis_stub.h +++ b/google/cloud/redis/v1/internal/cloud_redis_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 @@ -137,6 +138,31 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -155,9 +181,16 @@ class DefaultCloudRedisStub : public CloudRedisStub { DefaultCloudRedisStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListInstances( grpc::ClientContext& context, Options const& options, @@ -256,6 +289,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -271,6 +328,10 @@ class DefaultCloudRedisStub : public CloudRedisStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..6989fb66f18e0 100644 --- a/google/cloud/redis/v1/internal/cloud_redis_stub_factory.cc +++ b/google/cloud/redis/v1/internal/cloud_redis_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,14 @@ std::shared_ptr CreateDefaultCloudRedisStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::redis::v1::CloudRedis::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..4c5a16635d081 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,61 @@ 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)); +} + +StreamRange +CloudRedisTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("redis_v1::CloudRedisConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +CloudRedisTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("redis_v1::CloudRedisConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status CloudRedisTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = + internal::MakeSpan("redis_v1::CloudRedisConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status CloudRedisTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("redis_v1::CloudRedisConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..8270f67fda3db 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..5eebe7d14adae 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,74 @@ 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)); +} + +StatusOr +CloudRedisTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.redis.v1.CloudRedis", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr CloudRedisTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.redis.v1.CloudRedis", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status CloudRedisTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.redis.v1.CloudRedis", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status CloudRedisTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.redis.v1.CloudRedis", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..c964996da585c 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..b4d0b12d75650 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,29 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/resourcemanager/v3/folders_client.cc b/google/cloud/resourcemanager/v3/folders_client.cc index bce2dc66b413c..ee087d4d742ea 100644 --- a/google/cloud/resourcemanager/v3/folders_client.cc +++ b/google/cloud/resourcemanager/v3/folders_client.cc @@ -369,6 +369,20 @@ FoldersClient::TestIamPermissions( return connection_->TestIamPermissions(request); } +StatusOr FoldersClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr FoldersClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace resourcemanager_v3 } // namespace cloud diff --git a/google/cloud/resourcemanager/v3/folders_client.h b/google/cloud/resourcemanager/v3/folders_client.h index cbd3a672df218..a325f4a35ee96 100644 --- a/google/cloud/resourcemanager/v3/folders_client.h +++ b/google/cloud/resourcemanager/v3/folders_client.h @@ -1308,6 +1308,66 @@ class FoldersClient { google::iam::v1::TestIamPermissionsRequest const& request, Options opts = {}); + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/resourcemanager/v3/folders_connection.cc b/google/cloud/resourcemanager/v3/folders_connection.cc index 4bcd6e0c66509..e21f4850d2dec 100644 --- a/google/cloud/resourcemanager/v3/folders_connection.cc +++ b/google/cloud/resourcemanager/v3/folders_connection.cc @@ -185,6 +185,11 @@ FoldersConnection::TestIamPermissions( return Status(StatusCode::kUnimplemented, "not implemented"); } +StatusOr FoldersConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeFoldersConnection(Options options) { internal::CheckExpectedOptions TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/resourcemanager/v3/folders_connection_idempotency_policy.cc b/google/cloud/resourcemanager/v3/folders_connection_idempotency_policy.cc index d75956a89f710..8448cc130158c 100644 --- a/google/cloud/resourcemanager/v3/folders_connection_idempotency_policy.cc +++ b/google/cloud/resourcemanager/v3/folders_connection_idempotency_policy.cc @@ -90,6 +90,11 @@ Idempotency FoldersConnectionIdempotencyPolicy::TestIamPermissions( return Idempotency::kIdempotent; } +Idempotency FoldersConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultFoldersConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/resourcemanager/v3/folders_connection_idempotency_policy.h b/google/cloud/resourcemanager/v3/folders_connection_idempotency_policy.h index 49473acef6b80..84a39dc875953 100644 --- a/google/cloud/resourcemanager/v3/folders_connection_idempotency_policy.h +++ b/google/cloud/resourcemanager/v3/folders_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -68,6 +69,9 @@ class FoldersConnectionIdempotencyPolicy { virtual google::cloud::Idempotency TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/resourcemanager/v3/internal/folders_auth_decorator.cc b/google/cloud/resourcemanager/v3/internal/folders_auth_decorator.cc index 693e14917c208..63dc10aa1c845 100644 --- a/google/cloud/resourcemanager/v3/internal/folders_auth_decorator.cc +++ b/google/cloud/resourcemanager/v3/internal/folders_auth_decorator.cc @@ -218,6 +218,14 @@ FoldersAuth::TestIamPermissions( return child_->TestIamPermissions(context, options, request); } +StatusOr FoldersAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + future> FoldersAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/resourcemanager/v3/internal/folders_auth_decorator.h b/google/cloud/resourcemanager/v3/internal/folders_auth_decorator.h index aa276116b654a..e4e8977805930 100644 --- a/google/cloud/resourcemanager/v3/internal/folders_auth_decorator.h +++ b/google/cloud/resourcemanager/v3/internal/folders_auth_decorator.h @@ -126,6 +126,10 @@ class FoldersAuth : public FoldersStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/resourcemanager/v3/internal/folders_connection_impl.cc b/google/cloud/resourcemanager/v3/internal/folders_connection_impl.cc index 6fd1bcc50ae61..8a3f707095e7c 100644 --- a/google/cloud/resourcemanager/v3/internal/folders_connection_impl.cc +++ b/google/cloud/resourcemanager/v3/internal/folders_connection_impl.cc @@ -653,6 +653,19 @@ FoldersConnectionImpl::TestIamPermissions( *current, request, __func__); } +StatusOr FoldersConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace resourcemanager_v3_internal } // namespace cloud diff --git a/google/cloud/resourcemanager/v3/internal/folders_connection_impl.h b/google/cloud/resourcemanager/v3/internal/folders_connection_impl.h index bf5cddfc604ae..c6d5b0214daa5 100644 --- a/google/cloud/resourcemanager/v3/internal/folders_connection_impl.h +++ b/google/cloud/resourcemanager/v3/internal/folders_connection_impl.h @@ -131,6 +131,9 @@ class FoldersConnectionImpl : public resourcemanager_v3::FoldersConnection { StatusOr TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/resourcemanager/v3/internal/folders_logging_decorator.cc b/google/cloud/resourcemanager/v3/internal/folders_logging_decorator.cc index 2b6e300ca39ce..ae121d3920960 100644 --- a/google/cloud/resourcemanager/v3/internal/folders_logging_decorator.cc +++ b/google/cloud/resourcemanager/v3/internal/folders_logging_decorator.cc @@ -262,6 +262,17 @@ FoldersLogging::TestIamPermissions( context, options, request, __func__, tracing_options_); } +StatusOr FoldersLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> FoldersLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/resourcemanager/v3/internal/folders_logging_decorator.h b/google/cloud/resourcemanager/v3/internal/folders_logging_decorator.h index 05a95bb8f9e5f..08e25fe17da5d 100644 --- a/google/cloud/resourcemanager/v3/internal/folders_logging_decorator.h +++ b/google/cloud/resourcemanager/v3/internal/folders_logging_decorator.h @@ -126,6 +126,10 @@ class FoldersLogging : public FoldersStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/resourcemanager/v3/internal/folders_metadata_decorator.cc b/google/cloud/resourcemanager/v3/internal/folders_metadata_decorator.cc index 484621506587a..c05b59178cd47 100644 --- a/google/cloud/resourcemanager/v3/internal/folders_metadata_decorator.cc +++ b/google/cloud/resourcemanager/v3/internal/folders_metadata_decorator.cc @@ -196,6 +196,14 @@ FoldersMetadata::TestIamPermissions( return child_->TestIamPermissions(context, options, request); } +StatusOr FoldersMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + future> FoldersMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/resourcemanager/v3/internal/folders_metadata_decorator.h b/google/cloud/resourcemanager/v3/internal/folders_metadata_decorator.h index 53f1cad7b5bdc..8efb23c4b19ce 100644 --- a/google/cloud/resourcemanager/v3/internal/folders_metadata_decorator.h +++ b/google/cloud/resourcemanager/v3/internal/folders_metadata_decorator.h @@ -126,6 +126,10 @@ class FoldersMetadata : public FoldersStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/resourcemanager/v3/internal/folders_stub.cc b/google/cloud/resourcemanager/v3/internal/folders_stub.cc index ed563f2631380..bd7f7cd2b381d 100644 --- a/google/cloud/resourcemanager/v3/internal/folders_stub.cc +++ b/google/cloud/resourcemanager/v3/internal/folders_stub.cc @@ -251,6 +251,17 @@ DefaultFoldersStub::TestIamPermissions( return response; } +StatusOr DefaultFoldersStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultFoldersStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/resourcemanager/v3/internal/folders_stub.h b/google/cloud/resourcemanager/v3/internal/folders_stub.h index ced6293607be8..55a17bb652052 100644 --- a/google/cloud/resourcemanager/v3/internal/folders_stub.h +++ b/google/cloud/resourcemanager/v3/internal/folders_stub.h @@ -123,6 +123,10 @@ class FoldersStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -142,9 +146,13 @@ class DefaultFoldersStub : public FoldersStub { std::unique_ptr< google::cloud::resourcemanager::v3::Folders::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr GetFolder( grpc::ClientContext& context, Options const& options, @@ -233,6 +241,10 @@ class DefaultFoldersStub : public FoldersStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -248,6 +260,8 @@ class DefaultFoldersStub : public FoldersStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/resourcemanager/v3/internal/folders_stub_factory.cc b/google/cloud/resourcemanager/v3/internal/folders_stub_factory.cc index 2586231c727cd..9e222d6492f3c 100644 --- a/google/cloud/resourcemanager/v3/internal/folders_stub_factory.cc +++ b/google/cloud/resourcemanager/v3/internal/folders_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 CreateDefaultFoldersStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::resourcemanager::v3::Folders::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/resourcemanager/v3/internal/folders_tracing_connection.cc b/google/cloud/resourcemanager/v3/internal/folders_tracing_connection.cc index c4f5394c232d3..4f13f6895b45a 100644 --- a/google/cloud/resourcemanager/v3/internal/folders_tracing_connection.cc +++ b/google/cloud/resourcemanager/v3/internal/folders_tracing_connection.cc @@ -228,6 +228,14 @@ FoldersTracingConnection::TestIamPermissions( return internal::EndSpan(*span, child_->TestIamPermissions(request)); } +StatusOr FoldersTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("resourcemanager_v3::FoldersConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/resourcemanager/v3/internal/folders_tracing_connection.h b/google/cloud/resourcemanager/v3/internal/folders_tracing_connection.h index 8367b9f41aac2..61b0e244e5087 100644 --- a/google/cloud/resourcemanager/v3/internal/folders_tracing_connection.h +++ b/google/cloud/resourcemanager/v3/internal/folders_tracing_connection.h @@ -119,6 +119,9 @@ class FoldersTracingConnection : public resourcemanager_v3::FoldersConnection { StatusOr TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/resourcemanager/v3/internal/folders_tracing_stub.cc b/google/cloud/resourcemanager/v3/internal/folders_tracing_stub.cc index 23734a26da35a..69a4d46c819d5 100644 --- a/google/cloud/resourcemanager/v3/internal/folders_tracing_stub.cc +++ b/google/cloud/resourcemanager/v3/internal/folders_tracing_stub.cc @@ -227,6 +227,17 @@ FoldersTracingStub::TestIamPermissions( context, *span, child_->TestIamPermissions(context, options, request)); } +StatusOr FoldersTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.resourcemanager.v3.Folders", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + future> FoldersTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/resourcemanager/v3/internal/folders_tracing_stub.h b/google/cloud/resourcemanager/v3/internal/folders_tracing_stub.h index 768844e47ea04..aa4cc570895cf 100644 --- a/google/cloud/resourcemanager/v3/internal/folders_tracing_stub.h +++ b/google/cloud/resourcemanager/v3/internal/folders_tracing_stub.h @@ -125,6 +125,10 @@ class FoldersTracingStub : public FoldersStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/resourcemanager/v3/internal/organizations_auth_decorator.cc b/google/cloud/resourcemanager/v3/internal/organizations_auth_decorator.cc index 168efdf62d644..18b99ce1a2208 100644 --- a/google/cloud/resourcemanager/v3/internal/organizations_auth_decorator.cc +++ b/google/cloud/resourcemanager/v3/internal/organizations_auth_decorator.cc @@ -75,6 +75,14 @@ OrganizationsAuth::TestIamPermissions( return child_->TestIamPermissions(context, options, request); } +StatusOr OrganizationsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace resourcemanager_v3_internal } // namespace cloud diff --git a/google/cloud/resourcemanager/v3/internal/organizations_auth_decorator.h b/google/cloud/resourcemanager/v3/internal/organizations_auth_decorator.h index 61ac8c375be38..f7f15dcdaae71 100644 --- a/google/cloud/resourcemanager/v3/internal/organizations_auth_decorator.h +++ b/google/cloud/resourcemanager/v3/internal/organizations_auth_decorator.h @@ -61,6 +61,10 @@ class OrganizationsAuth : public OrganizationsStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/resourcemanager/v3/internal/organizations_connection_impl.cc b/google/cloud/resourcemanager/v3/internal/organizations_connection_impl.cc index aa0d0a6a68ddb..1cdf60294bbf9 100644 --- a/google/cloud/resourcemanager/v3/internal/organizations_connection_impl.cc +++ b/google/cloud/resourcemanager/v3/internal/organizations_connection_impl.cc @@ -151,6 +151,20 @@ OrganizationsConnectionImpl::TestIamPermissions( *current, request, __func__); } +StatusOr +OrganizationsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace resourcemanager_v3_internal } // namespace cloud diff --git a/google/cloud/resourcemanager/v3/internal/organizations_connection_impl.h b/google/cloud/resourcemanager/v3/internal/organizations_connection_impl.h index a5fd22b2dbc12..6acc327014aeb 100644 --- a/google/cloud/resourcemanager/v3/internal/organizations_connection_impl.h +++ b/google/cloud/resourcemanager/v3/internal/organizations_connection_impl.h @@ -67,6 +67,9 @@ class OrganizationsConnectionImpl StatusOr TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/resourcemanager/v3/internal/organizations_logging_decorator.cc b/google/cloud/resourcemanager/v3/internal/organizations_logging_decorator.cc index d53956fd5c799..2ce6b02171bd2 100644 --- a/google/cloud/resourcemanager/v3/internal/organizations_logging_decorator.cc +++ b/google/cloud/resourcemanager/v3/internal/organizations_logging_decorator.cc @@ -97,6 +97,17 @@ OrganizationsLogging::TestIamPermissions( context, options, request, __func__, tracing_options_); } +StatusOr OrganizationsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace resourcemanager_v3_internal } // namespace cloud diff --git a/google/cloud/resourcemanager/v3/internal/organizations_logging_decorator.h b/google/cloud/resourcemanager/v3/internal/organizations_logging_decorator.h index 3ddc1d87c90a9..787a302b96f0b 100644 --- a/google/cloud/resourcemanager/v3/internal/organizations_logging_decorator.h +++ b/google/cloud/resourcemanager/v3/internal/organizations_logging_decorator.h @@ -61,6 +61,10 @@ class OrganizationsLogging : public OrganizationsStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/resourcemanager/v3/internal/organizations_metadata_decorator.cc b/google/cloud/resourcemanager/v3/internal/organizations_metadata_decorator.cc index beb0fa28b078d..01b2497015f4d 100644 --- a/google/cloud/resourcemanager/v3/internal/organizations_metadata_decorator.cc +++ b/google/cloud/resourcemanager/v3/internal/organizations_metadata_decorator.cc @@ -90,6 +90,14 @@ OrganizationsMetadata::TestIamPermissions( return child_->TestIamPermissions(context, options, request); } +StatusOr OrganizationsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + void OrganizationsMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/resourcemanager/v3/internal/organizations_metadata_decorator.h b/google/cloud/resourcemanager/v3/internal/organizations_metadata_decorator.h index 49ee069c5ed64..d0179c4d1acad 100644 --- a/google/cloud/resourcemanager/v3/internal/organizations_metadata_decorator.h +++ b/google/cloud/resourcemanager/v3/internal/organizations_metadata_decorator.h @@ -61,6 +61,10 @@ class OrganizationsMetadata : public OrganizationsStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/resourcemanager/v3/internal/organizations_stub.cc b/google/cloud/resourcemanager/v3/internal/organizations_stub.cc index c883c05455c7f..c5e73b86f84d6 100644 --- a/google/cloud/resourcemanager/v3/internal/organizations_stub.cc +++ b/google/cloud/resourcemanager/v3/internal/organizations_stub.cc @@ -89,6 +89,17 @@ DefaultOrganizationsStub::TestIamPermissions( return response; } +StatusOr DefaultOrganizationsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace resourcemanager_v3_internal } // namespace cloud diff --git a/google/cloud/resourcemanager/v3/internal/organizations_stub.h b/google/cloud/resourcemanager/v3/internal/organizations_stub.h index 512eb439ee505..ba0b7cbeb4bfa 100644 --- a/google/cloud/resourcemanager/v3/internal/organizations_stub.h +++ b/google/cloud/resourcemanager/v3/internal/organizations_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -60,6 +61,10 @@ class OrganizationsStub { TestIamPermissions( grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; }; class DefaultOrganizationsStub : public OrganizationsStub { @@ -67,8 +72,11 @@ class DefaultOrganizationsStub : public OrganizationsStub { explicit DefaultOrganizationsStub( std::unique_ptr< google::cloud::resourcemanager::v3::Organizations::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr GetOrganization( grpc::ClientContext& context, Options const& options, @@ -93,10 +101,16 @@ class DefaultOrganizationsStub : public OrganizationsStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr< google::cloud::resourcemanager::v3::Organizations::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/resourcemanager/v3/internal/organizations_stub_factory.cc b/google/cloud/resourcemanager/v3/internal/organizations_stub_factory.cc index 7d05a572bc90f..062d3d2590114 100644 --- a/google/cloud/resourcemanager/v3/internal/organizations_stub_factory.cc +++ b/google/cloud/resourcemanager/v3/internal/organizations_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 CreateDefaultOrganizationsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::resourcemanager::v3::Organizations::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_stub)); if (auth->RequiresConfigureContext()) { stub = diff --git a/google/cloud/resourcemanager/v3/internal/organizations_tracing_connection.cc b/google/cloud/resourcemanager/v3/internal/organizations_tracing_connection.cc index 980adb9fdcfef..9ca76ab23ece1 100644 --- a/google/cloud/resourcemanager/v3/internal/organizations_tracing_connection.cc +++ b/google/cloud/resourcemanager/v3/internal/organizations_tracing_connection.cc @@ -79,6 +79,15 @@ OrganizationsTracingConnection::TestIamPermissions( return internal::EndSpan(*span, child_->TestIamPermissions(request)); } +StatusOr +OrganizationsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "resourcemanager_v3::OrganizationsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/resourcemanager/v3/internal/organizations_tracing_connection.h b/google/cloud/resourcemanager/v3/internal/organizations_tracing_connection.h index e45ea8a313fda..559077384ea46 100644 --- a/google/cloud/resourcemanager/v3/internal/organizations_tracing_connection.h +++ b/google/cloud/resourcemanager/v3/internal/organizations_tracing_connection.h @@ -58,6 +58,9 @@ class OrganizationsTracingConnection StatusOr TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/resourcemanager/v3/internal/organizations_tracing_stub.cc b/google/cloud/resourcemanager/v3/internal/organizations_tracing_stub.cc index a05054b6362e3..7ad7b426eb215 100644 --- a/google/cloud/resourcemanager/v3/internal/organizations_tracing_stub.cc +++ b/google/cloud/resourcemanager/v3/internal/organizations_tracing_stub.cc @@ -91,6 +91,17 @@ OrganizationsTracingStub::TestIamPermissions( context, *span, child_->TestIamPermissions(context, options, request)); } +StatusOr OrganizationsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.resourcemanager.v3.Organizations", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeOrganizationsTracingStub( diff --git a/google/cloud/resourcemanager/v3/internal/organizations_tracing_stub.h b/google/cloud/resourcemanager/v3/internal/organizations_tracing_stub.h index c96fdb263464e..79e14da9ad2c6 100644 --- a/google/cloud/resourcemanager/v3/internal/organizations_tracing_stub.h +++ b/google/cloud/resourcemanager/v3/internal/organizations_tracing_stub.h @@ -61,6 +61,10 @@ class OrganizationsTracingStub : public OrganizationsStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/resourcemanager/v3/internal/projects_auth_decorator.cc b/google/cloud/resourcemanager/v3/internal/projects_auth_decorator.cc index ac9c9d523c2fa..015a0fd398569 100644 --- a/google/cloud/resourcemanager/v3/internal/projects_auth_decorator.cc +++ b/google/cloud/resourcemanager/v3/internal/projects_auth_decorator.cc @@ -221,6 +221,14 @@ ProjectsAuth::TestIamPermissions( return child_->TestIamPermissions(context, options, request); } +StatusOr ProjectsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + future> ProjectsAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/resourcemanager/v3/internal/projects_auth_decorator.h b/google/cloud/resourcemanager/v3/internal/projects_auth_decorator.h index d7f86117efb37..21f71db62adce 100644 --- a/google/cloud/resourcemanager/v3/internal/projects_auth_decorator.h +++ b/google/cloud/resourcemanager/v3/internal/projects_auth_decorator.h @@ -127,6 +127,10 @@ class ProjectsAuth : public ProjectsStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/resourcemanager/v3/internal/projects_connection_impl.cc b/google/cloud/resourcemanager/v3/internal/projects_connection_impl.cc index 5ce8c7cd39e49..c7e50edf1af66 100644 --- a/google/cloud/resourcemanager/v3/internal/projects_connection_impl.cc +++ b/google/cloud/resourcemanager/v3/internal/projects_connection_impl.cc @@ -657,6 +657,19 @@ ProjectsConnectionImpl::TestIamPermissions( *current, request, __func__); } +StatusOr ProjectsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace resourcemanager_v3_internal } // namespace cloud diff --git a/google/cloud/resourcemanager/v3/internal/projects_connection_impl.h b/google/cloud/resourcemanager/v3/internal/projects_connection_impl.h index 31d07b9b1ffd9..945fcdee8f3ca 100644 --- a/google/cloud/resourcemanager/v3/internal/projects_connection_impl.h +++ b/google/cloud/resourcemanager/v3/internal/projects_connection_impl.h @@ -131,6 +131,9 @@ class ProjectsConnectionImpl : public resourcemanager_v3::ProjectsConnection { StatusOr TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/resourcemanager/v3/internal/projects_logging_decorator.cc b/google/cloud/resourcemanager/v3/internal/projects_logging_decorator.cc index a961ca840676c..02510fa6e5c75 100644 --- a/google/cloud/resourcemanager/v3/internal/projects_logging_decorator.cc +++ b/google/cloud/resourcemanager/v3/internal/projects_logging_decorator.cc @@ -263,6 +263,17 @@ ProjectsLogging::TestIamPermissions( context, options, request, __func__, tracing_options_); } +StatusOr ProjectsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> ProjectsLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/resourcemanager/v3/internal/projects_logging_decorator.h b/google/cloud/resourcemanager/v3/internal/projects_logging_decorator.h index b5da3aef56045..75d597b196952 100644 --- a/google/cloud/resourcemanager/v3/internal/projects_logging_decorator.h +++ b/google/cloud/resourcemanager/v3/internal/projects_logging_decorator.h @@ -127,6 +127,10 @@ class ProjectsLogging : public ProjectsStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/resourcemanager/v3/internal/projects_metadata_decorator.cc b/google/cloud/resourcemanager/v3/internal/projects_metadata_decorator.cc index ee551b3cbf7ce..b549fa6e1f334 100644 --- a/google/cloud/resourcemanager/v3/internal/projects_metadata_decorator.cc +++ b/google/cloud/resourcemanager/v3/internal/projects_metadata_decorator.cc @@ -197,6 +197,14 @@ ProjectsMetadata::TestIamPermissions( return child_->TestIamPermissions(context, options, request); } +StatusOr ProjectsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + future> ProjectsMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/resourcemanager/v3/internal/projects_metadata_decorator.h b/google/cloud/resourcemanager/v3/internal/projects_metadata_decorator.h index b317f89c9329f..19aae741fc9fd 100644 --- a/google/cloud/resourcemanager/v3/internal/projects_metadata_decorator.h +++ b/google/cloud/resourcemanager/v3/internal/projects_metadata_decorator.h @@ -127,6 +127,10 @@ class ProjectsMetadata : public ProjectsStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/resourcemanager/v3/internal/projects_stub.cc b/google/cloud/resourcemanager/v3/internal/projects_stub.cc index 468cd18eb9fb7..1aa054221fe68 100644 --- a/google/cloud/resourcemanager/v3/internal/projects_stub.cc +++ b/google/cloud/resourcemanager/v3/internal/projects_stub.cc @@ -251,6 +251,17 @@ DefaultProjectsStub::TestIamPermissions( return response; } +StatusOr DefaultProjectsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultProjectsStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/resourcemanager/v3/internal/projects_stub.h b/google/cloud/resourcemanager/v3/internal/projects_stub.h index 3a679034494db..2956cd2a2524c 100644 --- a/google/cloud/resourcemanager/v3/internal/projects_stub.h +++ b/google/cloud/resourcemanager/v3/internal/projects_stub.h @@ -126,6 +126,10 @@ class ProjectsStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -145,9 +149,13 @@ class DefaultProjectsStub : public ProjectsStub { std::unique_ptr< google::cloud::resourcemanager::v3::Projects::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr GetProject( grpc::ClientContext& context, Options const& options, @@ -237,6 +245,10 @@ class DefaultProjectsStub : public ProjectsStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -252,6 +264,8 @@ class DefaultProjectsStub : public ProjectsStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/resourcemanager/v3/internal/projects_stub_factory.cc b/google/cloud/resourcemanager/v3/internal/projects_stub_factory.cc index c5aab6c83243a..9b366510f879c 100644 --- a/google/cloud/resourcemanager/v3/internal/projects_stub_factory.cc +++ b/google/cloud/resourcemanager/v3/internal/projects_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 CreateDefaultProjectsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::resourcemanager::v3::Projects::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/resourcemanager/v3/internal/projects_tracing_connection.cc b/google/cloud/resourcemanager/v3/internal/projects_tracing_connection.cc index 7bac2a01e590f..ee4decb00d415 100644 --- a/google/cloud/resourcemanager/v3/internal/projects_tracing_connection.cc +++ b/google/cloud/resourcemanager/v3/internal/projects_tracing_connection.cc @@ -231,6 +231,15 @@ ProjectsTracingConnection::TestIamPermissions( return internal::EndSpan(*span, child_->TestIamPermissions(request)); } +StatusOr +ProjectsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "resourcemanager_v3::ProjectsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/resourcemanager/v3/internal/projects_tracing_connection.h b/google/cloud/resourcemanager/v3/internal/projects_tracing_connection.h index 328157f67a29a..9269e2b1b9c5b 100644 --- a/google/cloud/resourcemanager/v3/internal/projects_tracing_connection.h +++ b/google/cloud/resourcemanager/v3/internal/projects_tracing_connection.h @@ -120,6 +120,9 @@ class ProjectsTracingConnection StatusOr TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/resourcemanager/v3/internal/projects_tracing_stub.cc b/google/cloud/resourcemanager/v3/internal/projects_tracing_stub.cc index 6be610ae28410..eb278c5b538a2 100644 --- a/google/cloud/resourcemanager/v3/internal/projects_tracing_stub.cc +++ b/google/cloud/resourcemanager/v3/internal/projects_tracing_stub.cc @@ -227,6 +227,17 @@ ProjectsTracingStub::TestIamPermissions( context, *span, child_->TestIamPermissions(context, options, request)); } +StatusOr ProjectsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.resourcemanager.v3.Projects", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + future> ProjectsTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/resourcemanager/v3/internal/projects_tracing_stub.h b/google/cloud/resourcemanager/v3/internal/projects_tracing_stub.h index 1f5058e7a87ba..d30093af14c3a 100644 --- a/google/cloud/resourcemanager/v3/internal/projects_tracing_stub.h +++ b/google/cloud/resourcemanager/v3/internal/projects_tracing_stub.h @@ -126,6 +126,10 @@ class ProjectsTracingStub : public ProjectsStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/resourcemanager/v3/internal/tag_bindings_auth_decorator.cc b/google/cloud/resourcemanager/v3/internal/tag_bindings_auth_decorator.cc index 2ebeaaf6266ab..e91ab6fc7871d 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_bindings_auth_decorator.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_bindings_auth_decorator.cc @@ -110,6 +110,14 @@ TagBindingsAuth::ListEffectiveTags( return child_->ListEffectiveTags(context, options, request); } +StatusOr TagBindingsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + future> TagBindingsAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/resourcemanager/v3/internal/tag_bindings_auth_decorator.h b/google/cloud/resourcemanager/v3/internal/tag_bindings_auth_decorator.h index 587e41e83a275..f146c10a8499a 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_bindings_auth_decorator.h +++ b/google/cloud/resourcemanager/v3/internal/tag_bindings_auth_decorator.h @@ -75,6 +75,10 @@ class TagBindingsAuth : public TagBindingsStub { google::cloud::resourcemanager::v3::ListEffectiveTagsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/resourcemanager/v3/internal/tag_bindings_connection_impl.cc b/google/cloud/resourcemanager/v3/internal/tag_bindings_connection_impl.cc index b5ef100aabd24..7b9a8c0201800 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_bindings_connection_impl.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_bindings_connection_impl.cc @@ -328,6 +328,20 @@ TagBindingsConnectionImpl::ListEffectiveTags( }); } +StatusOr +TagBindingsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace resourcemanager_v3_internal } // namespace cloud diff --git a/google/cloud/resourcemanager/v3/internal/tag_bindings_connection_impl.h b/google/cloud/resourcemanager/v3/internal/tag_bindings_connection_impl.h index 20383b37b5733..786298f857087 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_bindings_connection_impl.h +++ b/google/cloud/resourcemanager/v3/internal/tag_bindings_connection_impl.h @@ -86,6 +86,9 @@ class TagBindingsConnectionImpl ListEffectiveTags(google::cloud::resourcemanager::v3::ListEffectiveTagsRequest request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/resourcemanager/v3/internal/tag_bindings_logging_decorator.cc b/google/cloud/resourcemanager/v3/internal/tag_bindings_logging_decorator.cc index 646ab4b759d35..a753b51839475 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_bindings_logging_decorator.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_bindings_logging_decorator.cc @@ -128,6 +128,17 @@ TagBindingsLogging::ListEffectiveTags( context, options, request, __func__, tracing_options_); } +StatusOr TagBindingsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> TagBindingsLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/resourcemanager/v3/internal/tag_bindings_logging_decorator.h b/google/cloud/resourcemanager/v3/internal/tag_bindings_logging_decorator.h index 602637d9796e1..9f1be453c45d2 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_bindings_logging_decorator.h +++ b/google/cloud/resourcemanager/v3/internal/tag_bindings_logging_decorator.h @@ -75,6 +75,10 @@ class TagBindingsLogging : public TagBindingsStub { google::cloud::resourcemanager::v3::ListEffectiveTagsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/resourcemanager/v3/internal/tag_bindings_metadata_decorator.cc b/google/cloud/resourcemanager/v3/internal/tag_bindings_metadata_decorator.cc index d48bcdaf8e247..e604b67578ad9 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_bindings_metadata_decorator.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_bindings_metadata_decorator.cc @@ -103,6 +103,14 @@ TagBindingsMetadata::ListEffectiveTags( return child_->ListEffectiveTags(context, options, request); } +StatusOr TagBindingsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + future> TagBindingsMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/resourcemanager/v3/internal/tag_bindings_metadata_decorator.h b/google/cloud/resourcemanager/v3/internal/tag_bindings_metadata_decorator.h index ce99ff58bdb24..b2d1f954ef8e9 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_bindings_metadata_decorator.h +++ b/google/cloud/resourcemanager/v3/internal/tag_bindings_metadata_decorator.h @@ -75,6 +75,10 @@ class TagBindingsMetadata : public TagBindingsStub { google::cloud::resourcemanager::v3::ListEffectiveTagsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/resourcemanager/v3/internal/tag_bindings_stub.cc b/google/cloud/resourcemanager/v3/internal/tag_bindings_stub.cc index 6282566e5fd9a..402711a691d8d 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_bindings_stub.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_bindings_stub.cc @@ -122,6 +122,17 @@ DefaultTagBindingsStub::ListEffectiveTags( return response; } +StatusOr DefaultTagBindingsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultTagBindingsStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/resourcemanager/v3/internal/tag_bindings_stub.h b/google/cloud/resourcemanager/v3/internal/tag_bindings_stub.h index 27f87118741ab..8766c7ec8d19b 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_bindings_stub.h +++ b/google/cloud/resourcemanager/v3/internal/tag_bindings_stub.h @@ -77,6 +77,10 @@ class TagBindingsStub { google::cloud::resourcemanager::v3::ListEffectiveTagsRequest const& request) = 0; + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -96,9 +100,13 @@ class DefaultTagBindingsStub : public TagBindingsStub { std::unique_ptr< google::cloud::resourcemanager::v3::TagBindings::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr ListTagBindings( @@ -136,6 +144,10 @@ class DefaultTagBindingsStub : public TagBindingsStub { google::cloud::resourcemanager::v3::ListEffectiveTagsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -152,6 +164,8 @@ class DefaultTagBindingsStub : public TagBindingsStub { std::unique_ptr< google::cloud::resourcemanager::v3::TagBindings::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/resourcemanager/v3/internal/tag_bindings_stub_factory.cc b/google/cloud/resourcemanager/v3/internal/tag_bindings_stub_factory.cc index 8fed0c2513c74..809540cbb399e 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_bindings_stub_factory.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_bindings_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 CreateDefaultTagBindingsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::resourcemanager::v3::TagBindings::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/resourcemanager/v3/internal/tag_bindings_tracing_connection.cc b/google/cloud/resourcemanager/v3/internal/tag_bindings_tracing_connection.cc index 516722ac50376..35661217c0f7a 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_bindings_tracing_connection.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_bindings_tracing_connection.cc @@ -121,6 +121,15 @@ TagBindingsTracingConnection::ListEffectiveTags( std::move(sr)); } +StatusOr +TagBindingsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "resourcemanager_v3::TagBindingsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/resourcemanager/v3/internal/tag_bindings_tracing_connection.h b/google/cloud/resourcemanager/v3/internal/tag_bindings_tracing_connection.h index 77afad7237724..b78993bfe4b4c 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_bindings_tracing_connection.h +++ b/google/cloud/resourcemanager/v3/internal/tag_bindings_tracing_connection.h @@ -74,6 +74,9 @@ class TagBindingsTracingConnection ListEffectiveTags(google::cloud::resourcemanager::v3::ListEffectiveTagsRequest request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/resourcemanager/v3/internal/tag_bindings_tracing_stub.cc b/google/cloud/resourcemanager/v3/internal/tag_bindings_tracing_stub.cc index 3e63361b2c6ec..6911838dd830f 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_bindings_tracing_stub.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_bindings_tracing_stub.cc @@ -115,6 +115,17 @@ TagBindingsTracingStub::ListEffectiveTags( context, *span, child_->ListEffectiveTags(context, options, request)); } +StatusOr TagBindingsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.resourcemanager.v3.TagBindings", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + future> TagBindingsTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/resourcemanager/v3/internal/tag_bindings_tracing_stub.h b/google/cloud/resourcemanager/v3/internal/tag_bindings_tracing_stub.h index c492d83dd4771..0d2b5dbdf8e36 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_bindings_tracing_stub.h +++ b/google/cloud/resourcemanager/v3/internal/tag_bindings_tracing_stub.h @@ -74,6 +74,10 @@ class TagBindingsTracingStub : public TagBindingsStub { google::cloud::resourcemanager::v3::ListEffectiveTagsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/resourcemanager/v3/internal/tag_holds_auth_decorator.cc b/google/cloud/resourcemanager/v3/internal/tag_holds_auth_decorator.cc index 2bf1bf14bc572..a3db0f70d7b3d 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_holds_auth_decorator.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_holds_auth_decorator.cc @@ -96,6 +96,14 @@ TagHoldsAuth::ListTagHolds( return child_->ListTagHolds(context, options, request); } +StatusOr TagHoldsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + future> TagHoldsAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/resourcemanager/v3/internal/tag_holds_auth_decorator.h b/google/cloud/resourcemanager/v3/internal/tag_holds_auth_decorator.h index 4b8116898e834..9f84d729c5202 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_holds_auth_decorator.h +++ b/google/cloud/resourcemanager/v3/internal/tag_holds_auth_decorator.h @@ -68,6 +68,10 @@ class TagHoldsAuth : public TagHoldsStub { google::cloud::resourcemanager::v3::ListTagHoldsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/resourcemanager/v3/internal/tag_holds_connection_impl.cc b/google/cloud/resourcemanager/v3/internal/tag_holds_connection_impl.cc index bf324257b189b..15768076e43ac 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_holds_connection_impl.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_holds_connection_impl.cc @@ -287,6 +287,19 @@ TagHoldsConnectionImpl::ListTagHolds( }); } +StatusOr TagHoldsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace resourcemanager_v3_internal } // namespace cloud diff --git a/google/cloud/resourcemanager/v3/internal/tag_holds_connection_impl.h b/google/cloud/resourcemanager/v3/internal/tag_holds_connection_impl.h index 960f937f38c2d..44f6ebdb9a222 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_holds_connection_impl.h +++ b/google/cloud/resourcemanager/v3/internal/tag_holds_connection_impl.h @@ -78,6 +78,9 @@ class TagHoldsConnectionImpl : public resourcemanager_v3::TagHoldsConnection { StreamRange ListTagHolds( google::cloud::resourcemanager::v3::ListTagHoldsRequest request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/resourcemanager/v3/internal/tag_holds_logging_decorator.cc b/google/cloud/resourcemanager/v3/internal/tag_holds_logging_decorator.cc index 37e4ccf8b5332..7a856bd9ad6a8 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_holds_logging_decorator.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_holds_logging_decorator.cc @@ -110,6 +110,17 @@ TagHoldsLogging::ListTagHolds( context, options, request, __func__, tracing_options_); } +StatusOr TagHoldsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> TagHoldsLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/resourcemanager/v3/internal/tag_holds_logging_decorator.h b/google/cloud/resourcemanager/v3/internal/tag_holds_logging_decorator.h index c655b6d3215a1..b85d86a325324 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_holds_logging_decorator.h +++ b/google/cloud/resourcemanager/v3/internal/tag_holds_logging_decorator.h @@ -68,6 +68,10 @@ class TagHoldsLogging : public TagHoldsStub { google::cloud::resourcemanager::v3::ListTagHoldsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/resourcemanager/v3/internal/tag_holds_metadata_decorator.cc b/google/cloud/resourcemanager/v3/internal/tag_holds_metadata_decorator.cc index 57ed0f6c4ae28..ed391988d002b 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_holds_metadata_decorator.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_holds_metadata_decorator.cc @@ -93,6 +93,14 @@ TagHoldsMetadata::ListTagHolds( return child_->ListTagHolds(context, options, request); } +StatusOr TagHoldsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + future> TagHoldsMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/resourcemanager/v3/internal/tag_holds_metadata_decorator.h b/google/cloud/resourcemanager/v3/internal/tag_holds_metadata_decorator.h index be1373e5962cd..45b426c90b5b0 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_holds_metadata_decorator.h +++ b/google/cloud/resourcemanager/v3/internal/tag_holds_metadata_decorator.h @@ -68,6 +68,10 @@ class TagHoldsMetadata : public TagHoldsStub { google::cloud::resourcemanager::v3::ListTagHoldsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/resourcemanager/v3/internal/tag_holds_stub.cc b/google/cloud/resourcemanager/v3/internal/tag_holds_stub.cc index aba70248b62f1..c45cc8d2b8fd7 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_holds_stub.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_holds_stub.cc @@ -103,6 +103,17 @@ DefaultTagHoldsStub::ListTagHolds( return response; } +StatusOr DefaultTagHoldsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultTagHoldsStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/resourcemanager/v3/internal/tag_holds_stub.h b/google/cloud/resourcemanager/v3/internal/tag_holds_stub.h index ae85b42c4e4b9..b88df7f766ea4 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_holds_stub.h +++ b/google/cloud/resourcemanager/v3/internal/tag_holds_stub.h @@ -67,6 +67,10 @@ class TagHoldsStub { google::cloud::resourcemanager::v3::ListTagHoldsRequest const& request) = 0; + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -86,9 +90,13 @@ class DefaultTagHoldsStub : public TagHoldsStub { std::unique_ptr< google::cloud::resourcemanager::v3::TagHolds::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateTagHold( google::cloud::CompletionQueue& cq, @@ -119,6 +127,10 @@ class DefaultTagHoldsStub : public TagHoldsStub { google::cloud::resourcemanager::v3::ListTagHoldsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -134,6 +146,8 @@ class DefaultTagHoldsStub : public TagHoldsStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/resourcemanager/v3/internal/tag_holds_stub_factory.cc b/google/cloud/resourcemanager/v3/internal/tag_holds_stub_factory.cc index 46772d7e3641d..6089bb92d87d4 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_holds_stub_factory.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_holds_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 CreateDefaultTagHoldsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::resourcemanager::v3::TagHolds::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/resourcemanager/v3/internal/tag_holds_tracing_connection.cc b/google/cloud/resourcemanager/v3/internal/tag_holds_tracing_connection.cc index 4ed8b5a0f00d8..7712c9dd2a6cf 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_holds_tracing_connection.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_holds_tracing_connection.cc @@ -101,6 +101,15 @@ TagHoldsTracingConnection::ListTagHolds( std::move(sr)); } +StatusOr +TagHoldsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "resourcemanager_v3::TagHoldsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/resourcemanager/v3/internal/tag_holds_tracing_connection.h b/google/cloud/resourcemanager/v3/internal/tag_holds_tracing_connection.h index ead8064bd070a..4485de39ff377 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_holds_tracing_connection.h +++ b/google/cloud/resourcemanager/v3/internal/tag_holds_tracing_connection.h @@ -67,6 +67,9 @@ class TagHoldsTracingConnection StreamRange ListTagHolds( google::cloud::resourcemanager::v3::ListTagHoldsRequest request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/resourcemanager/v3/internal/tag_holds_tracing_stub.cc b/google/cloud/resourcemanager/v3/internal/tag_holds_tracing_stub.cc index 650d03fab79ff..0a590f2805da6 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_holds_tracing_stub.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_holds_tracing_stub.cc @@ -93,6 +93,17 @@ TagHoldsTracingStub::ListTagHolds( child_->ListTagHolds(context, options, request)); } +StatusOr TagHoldsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.resourcemanager.v3.TagHolds", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + future> TagHoldsTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/resourcemanager/v3/internal/tag_holds_tracing_stub.h b/google/cloud/resourcemanager/v3/internal/tag_holds_tracing_stub.h index 08688c7a2913c..7b43a9b0147c6 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_holds_tracing_stub.h +++ b/google/cloud/resourcemanager/v3/internal/tag_holds_tracing_stub.h @@ -67,6 +67,10 @@ class TagHoldsTracingStub : public TagHoldsStub { google::cloud::resourcemanager::v3::ListTagHoldsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/resourcemanager/v3/internal/tag_keys_auth_decorator.cc b/google/cloud/resourcemanager/v3/internal/tag_keys_auth_decorator.cc index c3eddea521b03..fae3364235f90 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_keys_auth_decorator.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_keys_auth_decorator.cc @@ -164,6 +164,14 @@ TagKeysAuth::TestIamPermissions( return child_->TestIamPermissions(context, options, request); } +StatusOr TagKeysAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + future> TagKeysAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/resourcemanager/v3/internal/tag_keys_auth_decorator.h b/google/cloud/resourcemanager/v3/internal/tag_keys_auth_decorator.h index ac05de6198e0c..5179f8b3c1a24 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_keys_auth_decorator.h +++ b/google/cloud/resourcemanager/v3/internal/tag_keys_auth_decorator.h @@ -102,6 +102,10 @@ class TagKeysAuth : public TagKeysStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/resourcemanager/v3/internal/tag_keys_connection_impl.cc b/google/cloud/resourcemanager/v3/internal/tag_keys_connection_impl.cc index 4036e58b7061e..f57bb4cf694f3 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_keys_connection_impl.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_keys_connection_impl.cc @@ -449,6 +449,19 @@ TagKeysConnectionImpl::TestIamPermissions( *current, request, __func__); } +StatusOr TagKeysConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace resourcemanager_v3_internal } // namespace cloud diff --git a/google/cloud/resourcemanager/v3/internal/tag_keys_connection_impl.h b/google/cloud/resourcemanager/v3/internal/tag_keys_connection_impl.h index 84bb3706c1e57..e27ba357012bd 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_keys_connection_impl.h +++ b/google/cloud/resourcemanager/v3/internal/tag_keys_connection_impl.h @@ -107,6 +107,9 @@ class TagKeysConnectionImpl : public resourcemanager_v3::TagKeysConnection { StatusOr TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/resourcemanager/v3/internal/tag_keys_logging_decorator.cc b/google/cloud/resourcemanager/v3/internal/tag_keys_logging_decorator.cc index 9f853ce4291b6..529f22f4fed9e 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_keys_logging_decorator.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_keys_logging_decorator.cc @@ -202,6 +202,17 @@ TagKeysLogging::TestIamPermissions( context, options, request, __func__, tracing_options_); } +StatusOr TagKeysLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> TagKeysLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/resourcemanager/v3/internal/tag_keys_logging_decorator.h b/google/cloud/resourcemanager/v3/internal/tag_keys_logging_decorator.h index e43ab355799d9..38fefd78473fb 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_keys_logging_decorator.h +++ b/google/cloud/resourcemanager/v3/internal/tag_keys_logging_decorator.h @@ -102,6 +102,10 @@ class TagKeysLogging : public TagKeysStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/resourcemanager/v3/internal/tag_keys_metadata_decorator.cc b/google/cloud/resourcemanager/v3/internal/tag_keys_metadata_decorator.cc index ed56170346734..220c2cb9d4c98 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_keys_metadata_decorator.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_keys_metadata_decorator.cc @@ -157,6 +157,14 @@ TagKeysMetadata::TestIamPermissions( return child_->TestIamPermissions(context, options, request); } +StatusOr TagKeysMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + future> TagKeysMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/resourcemanager/v3/internal/tag_keys_metadata_decorator.h b/google/cloud/resourcemanager/v3/internal/tag_keys_metadata_decorator.h index 02119e7214674..8dbefce59b10b 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_keys_metadata_decorator.h +++ b/google/cloud/resourcemanager/v3/internal/tag_keys_metadata_decorator.h @@ -102,6 +102,10 @@ class TagKeysMetadata : public TagKeysStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/resourcemanager/v3/internal/tag_keys_stub.cc b/google/cloud/resourcemanager/v3/internal/tag_keys_stub.cc index 0343be0d158f8..c5c84b3093761 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_keys_stub.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_keys_stub.cc @@ -192,6 +192,17 @@ DefaultTagKeysStub::TestIamPermissions( return response; } +StatusOr DefaultTagKeysStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultTagKeysStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/resourcemanager/v3/internal/tag_keys_stub.h b/google/cloud/resourcemanager/v3/internal/tag_keys_stub.h index 99aae7819b97d..bb43d4517f566 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_keys_stub.h +++ b/google/cloud/resourcemanager/v3/internal/tag_keys_stub.h @@ -102,6 +102,10 @@ class TagKeysStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -121,9 +125,13 @@ class DefaultTagKeysStub : public TagKeysStub { std::unique_ptr< google::cloud::resourcemanager::v3::TagKeys::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr ListTagKeys( grpc::ClientContext& context, Options const& options, @@ -188,6 +196,10 @@ class DefaultTagKeysStub : public TagKeysStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -203,6 +215,8 @@ class DefaultTagKeysStub : public TagKeysStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/resourcemanager/v3/internal/tag_keys_stub_factory.cc b/google/cloud/resourcemanager/v3/internal/tag_keys_stub_factory.cc index 35ef766f78590..3bf6576f2eaa4 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_keys_stub_factory.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_keys_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 CreateDefaultTagKeysStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::resourcemanager::v3::TagKeys::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/resourcemanager/v3/internal/tag_keys_tracing_connection.cc b/google/cloud/resourcemanager/v3/internal/tag_keys_tracing_connection.cc index 0166270606af3..a9ad61dd32669 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_keys_tracing_connection.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_keys_tracing_connection.cc @@ -170,6 +170,14 @@ TagKeysTracingConnection::TestIamPermissions( return internal::EndSpan(*span, child_->TestIamPermissions(request)); } +StatusOr TagKeysTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("resourcemanager_v3::TagKeysConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/resourcemanager/v3/internal/tag_keys_tracing_connection.h b/google/cloud/resourcemanager/v3/internal/tag_keys_tracing_connection.h index 29c3e0f13808a..ad0c93454f6e8 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_keys_tracing_connection.h +++ b/google/cloud/resourcemanager/v3/internal/tag_keys_tracing_connection.h @@ -95,6 +95,9 @@ class TagKeysTracingConnection : public resourcemanager_v3::TagKeysConnection { StatusOr TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/resourcemanager/v3/internal/tag_keys_tracing_stub.cc b/google/cloud/resourcemanager/v3/internal/tag_keys_tracing_stub.cc index e0ff45f7ca78d..837efae9e26c9 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_keys_tracing_stub.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_keys_tracing_stub.cc @@ -177,6 +177,17 @@ TagKeysTracingStub::TestIamPermissions( context, *span, child_->TestIamPermissions(context, options, request)); } +StatusOr TagKeysTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.resourcemanager.v3.TagKeys", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + future> TagKeysTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/resourcemanager/v3/internal/tag_keys_tracing_stub.h b/google/cloud/resourcemanager/v3/internal/tag_keys_tracing_stub.h index 5775ad325cf64..c74c3b0ba351c 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_keys_tracing_stub.h +++ b/google/cloud/resourcemanager/v3/internal/tag_keys_tracing_stub.h @@ -101,6 +101,10 @@ class TagKeysTracingStub : public TagKeysStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/resourcemanager/v3/internal/tag_values_auth_decorator.cc b/google/cloud/resourcemanager/v3/internal/tag_values_auth_decorator.cc index 069a941eaa9ca..b4cfe228b197a 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_values_auth_decorator.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_values_auth_decorator.cc @@ -168,6 +168,14 @@ TagValuesAuth::TestIamPermissions( return child_->TestIamPermissions(context, options, request); } +StatusOr TagValuesAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + future> TagValuesAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/resourcemanager/v3/internal/tag_values_auth_decorator.h b/google/cloud/resourcemanager/v3/internal/tag_values_auth_decorator.h index 657b788ede0c6..4b278fbe24ded 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_values_auth_decorator.h +++ b/google/cloud/resourcemanager/v3/internal/tag_values_auth_decorator.h @@ -102,6 +102,10 @@ class TagValuesAuth : public TagValuesStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/resourcemanager/v3/internal/tag_values_connection_impl.cc b/google/cloud/resourcemanager/v3/internal/tag_values_connection_impl.cc index c053f96717260..f75268407267c 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_values_connection_impl.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_values_connection_impl.cc @@ -454,6 +454,19 @@ TagValuesConnectionImpl::TestIamPermissions( *current, request, __func__); } +StatusOr TagValuesConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace resourcemanager_v3_internal } // namespace cloud diff --git a/google/cloud/resourcemanager/v3/internal/tag_values_connection_impl.h b/google/cloud/resourcemanager/v3/internal/tag_values_connection_impl.h index d661658e3214f..06581bde0b29e 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_values_connection_impl.h +++ b/google/cloud/resourcemanager/v3/internal/tag_values_connection_impl.h @@ -108,6 +108,9 @@ class TagValuesConnectionImpl : public resourcemanager_v3::TagValuesConnection { StatusOr TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/resourcemanager/v3/internal/tag_values_logging_decorator.cc b/google/cloud/resourcemanager/v3/internal/tag_values_logging_decorator.cc index e854df2d87beb..044c0af2cc0ca 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_values_logging_decorator.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_values_logging_decorator.cc @@ -202,6 +202,17 @@ TagValuesLogging::TestIamPermissions( context, options, request, __func__, tracing_options_); } +StatusOr TagValuesLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> TagValuesLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/resourcemanager/v3/internal/tag_values_logging_decorator.h b/google/cloud/resourcemanager/v3/internal/tag_values_logging_decorator.h index 199e732fc4b94..f16fcf0db7e79 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_values_logging_decorator.h +++ b/google/cloud/resourcemanager/v3/internal/tag_values_logging_decorator.h @@ -102,6 +102,10 @@ class TagValuesLogging : public TagValuesStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/resourcemanager/v3/internal/tag_values_metadata_decorator.cc b/google/cloud/resourcemanager/v3/internal/tag_values_metadata_decorator.cc index 4a04c3e365ca9..2b59196d5934e 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_values_metadata_decorator.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_values_metadata_decorator.cc @@ -158,6 +158,14 @@ TagValuesMetadata::TestIamPermissions( return child_->TestIamPermissions(context, options, request); } +StatusOr TagValuesMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + future> TagValuesMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/resourcemanager/v3/internal/tag_values_metadata_decorator.h b/google/cloud/resourcemanager/v3/internal/tag_values_metadata_decorator.h index e8442e7fc4af4..ff7334169b932 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_values_metadata_decorator.h +++ b/google/cloud/resourcemanager/v3/internal/tag_values_metadata_decorator.h @@ -102,6 +102,10 @@ class TagValuesMetadata : public TagValuesStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/resourcemanager/v3/internal/tag_values_stub.cc b/google/cloud/resourcemanager/v3/internal/tag_values_stub.cc index 65edf8534c7f5..e56b3520a1bea 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_values_stub.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_values_stub.cc @@ -192,6 +192,17 @@ DefaultTagValuesStub::TestIamPermissions( return response; } +StatusOr DefaultTagValuesStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultTagValuesStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/resourcemanager/v3/internal/tag_values_stub.h b/google/cloud/resourcemanager/v3/internal/tag_values_stub.h index 5e986ef66c932..6b7b77197b922 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_values_stub.h +++ b/google/cloud/resourcemanager/v3/internal/tag_values_stub.h @@ -103,6 +103,10 @@ class TagValuesStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -122,9 +126,13 @@ class DefaultTagValuesStub : public TagValuesStub { std::unique_ptr< google::cloud::resourcemanager::v3::TagValues::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr ListTagValues(grpc::ClientContext& context, Options const& options, @@ -189,6 +197,10 @@ class DefaultTagValuesStub : public TagValuesStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -204,6 +216,8 @@ class DefaultTagValuesStub : public TagValuesStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/resourcemanager/v3/internal/tag_values_stub_factory.cc b/google/cloud/resourcemanager/v3/internal/tag_values_stub_factory.cc index aef301c2e0e0d..076f12b4d5941 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_values_stub_factory.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_values_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 CreateDefaultTagValuesStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::resourcemanager::v3::TagValues::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/resourcemanager/v3/internal/tag_values_tracing_connection.cc b/google/cloud/resourcemanager/v3/internal/tag_values_tracing_connection.cc index d2d6eca5d47d7..cc20472b63299 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_values_tracing_connection.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_values_tracing_connection.cc @@ -176,6 +176,15 @@ TagValuesTracingConnection::TestIamPermissions( return internal::EndSpan(*span, child_->TestIamPermissions(request)); } +StatusOr +TagValuesTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "resourcemanager_v3::TagValuesConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/resourcemanager/v3/internal/tag_values_tracing_connection.h b/google/cloud/resourcemanager/v3/internal/tag_values_tracing_connection.h index 7b953120faac4..53bc2779c17a3 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_values_tracing_connection.h +++ b/google/cloud/resourcemanager/v3/internal/tag_values_tracing_connection.h @@ -97,6 +97,9 @@ class TagValuesTracingConnection StatusOr TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/resourcemanager/v3/internal/tag_values_tracing_stub.cc b/google/cloud/resourcemanager/v3/internal/tag_values_tracing_stub.cc index f65eba68f2921..6d4ef6b6a9037 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_values_tracing_stub.cc +++ b/google/cloud/resourcemanager/v3/internal/tag_values_tracing_stub.cc @@ -180,6 +180,17 @@ TagValuesTracingStub::TestIamPermissions( context, *span, child_->TestIamPermissions(context, options, request)); } +StatusOr TagValuesTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.resourcemanager.v3.TagValues", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + future> TagValuesTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/resourcemanager/v3/internal/tag_values_tracing_stub.h b/google/cloud/resourcemanager/v3/internal/tag_values_tracing_stub.h index b16f783260562..e02a3bcf0ac63 100644 --- a/google/cloud/resourcemanager/v3/internal/tag_values_tracing_stub.h +++ b/google/cloud/resourcemanager/v3/internal/tag_values_tracing_stub.h @@ -101,6 +101,10 @@ class TagValuesTracingStub : public TagValuesStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/resourcemanager/v3/mocks/mock_folders_connection.h b/google/cloud/resourcemanager/v3/mocks/mock_folders_connection.h index 6aed8fc7dcf81..5a169a2c8ed8f 100644 --- a/google/cloud/resourcemanager/v3/mocks/mock_folders_connection.h +++ b/google/cloud/resourcemanager/v3/mocks/mock_folders_connection.h @@ -267,6 +267,10 @@ class MockFoldersConnection : public resourcemanager_v3::FoldersConnection { TestIamPermissions, (google::iam::v1::TestIamPermissionsRequest const& request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/resourcemanager/v3/mocks/mock_organizations_connection.h b/google/cloud/resourcemanager/v3/mocks/mock_organizations_connection.h index 9558e2a3b569c..561d92a7fe2e1 100644 --- a/google/cloud/resourcemanager/v3/mocks/mock_organizations_connection.h +++ b/google/cloud/resourcemanager/v3/mocks/mock_organizations_connection.h @@ -71,6 +71,10 @@ class MockOrganizationsConnection TestIamPermissions, (google::iam::v1::TestIamPermissionsRequest const& request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/resourcemanager/v3/mocks/mock_projects_connection.h b/google/cloud/resourcemanager/v3/mocks/mock_projects_connection.h index 24ef3dfb3eb03..aa4cb1b0f61a9 100644 --- a/google/cloud/resourcemanager/v3/mocks/mock_projects_connection.h +++ b/google/cloud/resourcemanager/v3/mocks/mock_projects_connection.h @@ -269,6 +269,10 @@ class MockProjectsConnection : public resourcemanager_v3::ProjectsConnection { TestIamPermissions, (google::iam::v1::TestIamPermissionsRequest const& request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/resourcemanager/v3/mocks/mock_tag_bindings_connection.h b/google/cloud/resourcemanager/v3/mocks/mock_tag_bindings_connection.h index 62a81053b07b4..b7d1f676a3751 100644 --- a/google/cloud/resourcemanager/v3/mocks/mock_tag_bindings_connection.h +++ b/google/cloud/resourcemanager/v3/mocks/mock_tag_bindings_connection.h @@ -143,6 +143,10 @@ class MockTagBindingsConnection ListEffectiveTags, (google::cloud::resourcemanager::v3::ListEffectiveTagsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/resourcemanager/v3/mocks/mock_tag_holds_connection.h b/google/cloud/resourcemanager/v3/mocks/mock_tag_holds_connection.h index 7cc61e7e7aabc..ba440327ade3b 100644 --- a/google/cloud/resourcemanager/v3/mocks/mock_tag_holds_connection.h +++ b/google/cloud/resourcemanager/v3/mocks/mock_tag_holds_connection.h @@ -131,6 +131,10 @@ class MockTagHoldsConnection : public resourcemanager_v3::TagHoldsConnection { ListTagHolds, (google::cloud::resourcemanager::v3::ListTagHoldsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/resourcemanager/v3/mocks/mock_tag_keys_connection.h b/google/cloud/resourcemanager/v3/mocks/mock_tag_keys_connection.h index 050f5a040dec2..314bba35b9386 100644 --- a/google/cloud/resourcemanager/v3/mocks/mock_tag_keys_connection.h +++ b/google/cloud/resourcemanager/v3/mocks/mock_tag_keys_connection.h @@ -191,6 +191,10 @@ class MockTagKeysConnection : public resourcemanager_v3::TagKeysConnection { TestIamPermissions, (google::iam::v1::TestIamPermissionsRequest const& request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/resourcemanager/v3/mocks/mock_tag_values_connection.h b/google/cloud/resourcemanager/v3/mocks/mock_tag_values_connection.h index 8f01aa7906c91..ad0bf9ccbcd5b 100644 --- a/google/cloud/resourcemanager/v3/mocks/mock_tag_values_connection.h +++ b/google/cloud/resourcemanager/v3/mocks/mock_tag_values_connection.h @@ -193,6 +193,10 @@ class MockTagValuesConnection : public resourcemanager_v3::TagValuesConnection { TestIamPermissions, (google::iam::v1::TestIamPermissionsRequest const& request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/resourcemanager/v3/organizations_client.cc b/google/cloud/resourcemanager/v3/organizations_client.cc index 188d9750f73ca..168771f34cd4d 100644 --- a/google/cloud/resourcemanager/v3/organizations_client.cc +++ b/google/cloud/resourcemanager/v3/organizations_client.cc @@ -111,6 +111,20 @@ OrganizationsClient::TestIamPermissions( return connection_->TestIamPermissions(request); } +StatusOr OrganizationsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr OrganizationsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace resourcemanager_v3 } // namespace cloud diff --git a/google/cloud/resourcemanager/v3/organizations_client.h b/google/cloud/resourcemanager/v3/organizations_client.h index 3cc29586c049b..ad82408dd7cd3 100644 --- a/google/cloud/resourcemanager/v3/organizations_client.h +++ b/google/cloud/resourcemanager/v3/organizations_client.h @@ -449,6 +449,66 @@ class OrganizationsClient { google::iam::v1::TestIamPermissionsRequest const& request, Options opts = {}); + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/resourcemanager/v3/organizations_connection.cc b/google/cloud/resourcemanager/v3/organizations_connection.cc index caa1b5a551da2..a1e09cf95f5c6 100644 --- a/google/cloud/resourcemanager/v3/organizations_connection.cc +++ b/google/cloud/resourcemanager/v3/organizations_connection.cc @@ -68,6 +68,11 @@ OrganizationsConnection::TestIamPermissions( return Status(StatusCode::kUnimplemented, "not implemented"); } +StatusOr OrganizationsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeOrganizationsConnection( Options options) { internal::CheckExpectedOptions TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/resourcemanager/v3/organizations_connection_idempotency_policy.cc b/google/cloud/resourcemanager/v3/organizations_connection_idempotency_policy.cc index 9bd31715e64d2..ed337bbf31de0 100644 --- a/google/cloud/resourcemanager/v3/organizations_connection_idempotency_policy.cc +++ b/google/cloud/resourcemanager/v3/organizations_connection_idempotency_policy.cc @@ -60,6 +60,11 @@ Idempotency OrganizationsConnectionIdempotencyPolicy::TestIamPermissions( return Idempotency::kIdempotent; } +Idempotency OrganizationsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultOrganizationsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/resourcemanager/v3/organizations_connection_idempotency_policy.h b/google/cloud/resourcemanager/v3/organizations_connection_idempotency_policy.h index fa3376e7adda4..291d35217cf59 100644 --- a/google/cloud/resourcemanager/v3/organizations_connection_idempotency_policy.h +++ b/google/cloud/resourcemanager/v3/organizations_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -52,6 +53,9 @@ class OrganizationsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/resourcemanager/v3/projects_client.cc b/google/cloud/resourcemanager/v3/projects_client.cc index 8153704594e2f..a8c337818718f 100644 --- a/google/cloud/resourcemanager/v3/projects_client.cc +++ b/google/cloud/resourcemanager/v3/projects_client.cc @@ -335,6 +335,20 @@ ProjectsClient::TestIamPermissions( return connection_->TestIamPermissions(request); } +StatusOr ProjectsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr ProjectsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace resourcemanager_v3 } // namespace cloud diff --git a/google/cloud/resourcemanager/v3/projects_client.h b/google/cloud/resourcemanager/v3/projects_client.h index ea83bd95ae76a..5ed2a01c35817 100644 --- a/google/cloud/resourcemanager/v3/projects_client.h +++ b/google/cloud/resourcemanager/v3/projects_client.h @@ -1315,6 +1315,66 @@ class ProjectsClient { google::iam::v1::TestIamPermissionsRequest const& request, Options opts = {}); + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/resourcemanager/v3/projects_connection.cc b/google/cloud/resourcemanager/v3/projects_connection.cc index 14099f5fa71c8..6991d32d0c94c 100644 --- a/google/cloud/resourcemanager/v3/projects_connection.cc +++ b/google/cloud/resourcemanager/v3/projects_connection.cc @@ -185,6 +185,11 @@ ProjectsConnection::TestIamPermissions( return Status(StatusCode::kUnimplemented, "not implemented"); } +StatusOr ProjectsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeProjectsConnection(Options options) { internal::CheckExpectedOptions TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/resourcemanager/v3/projects_connection_idempotency_policy.cc b/google/cloud/resourcemanager/v3/projects_connection_idempotency_policy.cc index c6902024733b0..e00d5c91454d7 100644 --- a/google/cloud/resourcemanager/v3/projects_connection_idempotency_policy.cc +++ b/google/cloud/resourcemanager/v3/projects_connection_idempotency_policy.cc @@ -90,6 +90,11 @@ Idempotency ProjectsConnectionIdempotencyPolicy::TestIamPermissions( return Idempotency::kIdempotent; } +Idempotency ProjectsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultProjectsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/resourcemanager/v3/projects_connection_idempotency_policy.h b/google/cloud/resourcemanager/v3/projects_connection_idempotency_policy.h index bc061a5c7a49f..0ac4b06c7d67d 100644 --- a/google/cloud/resourcemanager/v3/projects_connection_idempotency_policy.h +++ b/google/cloud/resourcemanager/v3/projects_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 ProjectsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/resourcemanager/v3/tag_bindings_client.cc b/google/cloud/resourcemanager/v3/tag_bindings_client.cc index 1961f7010fbf3..4da6613bb8a09 100644 --- a/google/cloud/resourcemanager/v3/tag_bindings_client.cc +++ b/google/cloud/resourcemanager/v3/tag_bindings_client.cc @@ -146,6 +146,20 @@ TagBindingsClient::ListEffectiveTags( return connection_->ListEffectiveTags(std::move(request)); } +StatusOr TagBindingsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr TagBindingsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace resourcemanager_v3 } // namespace cloud diff --git a/google/cloud/resourcemanager/v3/tag_bindings_client.h b/google/cloud/resourcemanager/v3/tag_bindings_client.h index 0c0496601e280..eee70b2d9b096 100644 --- a/google/cloud/resourcemanager/v3/tag_bindings_client.h +++ b/google/cloud/resourcemanager/v3/tag_bindings_client.h @@ -489,6 +489,66 @@ class TagBindingsClient { google::cloud::resourcemanager::v3::ListEffectiveTagsRequest request, Options opts = {}); + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/resourcemanager/v3/tag_bindings_connection.cc b/google/cloud/resourcemanager/v3/tag_bindings_connection.cc index b18814795de97..f5b5e8dc4d58c 100644 --- a/google/cloud/resourcemanager/v3/tag_bindings_connection.cc +++ b/google/cloud/resourcemanager/v3/tag_bindings_connection.cc @@ -100,6 +100,11 @@ TagBindingsConnection::ListEffectiveTags( StreamRange>(); } +StatusOr TagBindingsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeTagBindingsConnection( Options options) { internal::CheckExpectedOptions ListEffectiveTags( google::cloud::resourcemanager::v3::ListEffectiveTagsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/resourcemanager/v3/tag_bindings_connection_idempotency_policy.cc b/google/cloud/resourcemanager/v3/tag_bindings_connection_idempotency_policy.cc index 1becb3edc6dbb..491c6dbb7bf95 100644 --- a/google/cloud/resourcemanager/v3/tag_bindings_connection_idempotency_policy.cc +++ b/google/cloud/resourcemanager/v3/tag_bindings_connection_idempotency_policy.cc @@ -54,6 +54,11 @@ Idempotency TagBindingsConnectionIdempotencyPolicy::ListEffectiveTags( return Idempotency::kIdempotent; } +Idempotency TagBindingsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultTagBindingsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/resourcemanager/v3/tag_bindings_connection_idempotency_policy.h b/google/cloud/resourcemanager/v3/tag_bindings_connection_idempotency_policy.h index dab6319fde4d6..08b3c50fe5f24 100644 --- a/google/cloud/resourcemanager/v3/tag_bindings_connection_idempotency_policy.h +++ b/google/cloud/resourcemanager/v3/tag_bindings_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -49,6 +50,9 @@ class TagBindingsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListEffectiveTags( google::cloud::resourcemanager::v3::ListEffectiveTagsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/resourcemanager/v3/tag_holds_client.cc b/google/cloud/resourcemanager/v3/tag_holds_client.cc index 684301acb2795..844ab0bdfe91a 100644 --- a/google/cloud/resourcemanager/v3/tag_holds_client.cc +++ b/google/cloud/resourcemanager/v3/tag_holds_client.cc @@ -131,6 +131,20 @@ TagHoldsClient::ListTagHolds( return connection_->ListTagHolds(std::move(request)); } +StatusOr TagHoldsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr TagHoldsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace resourcemanager_v3 } // namespace cloud diff --git a/google/cloud/resourcemanager/v3/tag_holds_client.h b/google/cloud/resourcemanager/v3/tag_holds_client.h index 71b5207595796..b3332fade0a7e 100644 --- a/google/cloud/resourcemanager/v3/tag_holds_client.h +++ b/google/cloud/resourcemanager/v3/tag_holds_client.h @@ -399,6 +399,66 @@ class TagHoldsClient { google::cloud::resourcemanager::v3::ListTagHoldsRequest request, Options opts = {}); + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/resourcemanager/v3/tag_holds_connection.cc b/google/cloud/resourcemanager/v3/tag_holds_connection.cc index 12325df8cd4a3..4bf3bf89add16 100644 --- a/google/cloud/resourcemanager/v3/tag_holds_connection.cc +++ b/google/cloud/resourcemanager/v3/tag_holds_connection.cc @@ -90,6 +90,11 @@ TagHoldsConnection::ListTagHolds( StreamRange>(); } +StatusOr TagHoldsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeTagHoldsConnection(Options options) { internal::CheckExpectedOptions ListTagHolds( google::cloud::resourcemanager::v3::ListTagHoldsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/resourcemanager/v3/tag_holds_connection_idempotency_policy.cc b/google/cloud/resourcemanager/v3/tag_holds_connection_idempotency_policy.cc index 3906ad5dc6454..f80154e72118c 100644 --- a/google/cloud/resourcemanager/v3/tag_holds_connection_idempotency_policy.cc +++ b/google/cloud/resourcemanager/v3/tag_holds_connection_idempotency_policy.cc @@ -49,6 +49,11 @@ Idempotency TagHoldsConnectionIdempotencyPolicy::ListTagHolds( return Idempotency::kIdempotent; } +Idempotency TagHoldsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultTagHoldsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/resourcemanager/v3/tag_holds_connection_idempotency_policy.h b/google/cloud/resourcemanager/v3/tag_holds_connection_idempotency_policy.h index 875a1f141764a..fafa0875801a4 100644 --- a/google/cloud/resourcemanager/v3/tag_holds_connection_idempotency_policy.h +++ b/google/cloud/resourcemanager/v3/tag_holds_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,9 @@ class TagHoldsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListTagHolds( google::cloud::resourcemanager::v3::ListTagHoldsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/resourcemanager/v3/tag_keys_client.cc b/google/cloud/resourcemanager/v3/tag_keys_client.cc index 8959781391e02..dbdb403fcc166 100644 --- a/google/cloud/resourcemanager/v3/tag_keys_client.cc +++ b/google/cloud/resourcemanager/v3/tag_keys_client.cc @@ -288,6 +288,20 @@ TagKeysClient::TestIamPermissions( return connection_->TestIamPermissions(request); } +StatusOr TagKeysClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr TagKeysClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace resourcemanager_v3 } // namespace cloud diff --git a/google/cloud/resourcemanager/v3/tag_keys_client.h b/google/cloud/resourcemanager/v3/tag_keys_client.h index f2358ada14e5b..9fdf9cfff36b2 100644 --- a/google/cloud/resourcemanager/v3/tag_keys_client.h +++ b/google/cloud/resourcemanager/v3/tag_keys_client.h @@ -874,6 +874,66 @@ class TagKeysClient { google::iam::v1::TestIamPermissionsRequest const& request, Options opts = {}); + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/resourcemanager/v3/tag_keys_connection.cc b/google/cloud/resourcemanager/v3/tag_keys_connection.cc index 5ec5ca059fcb6..cc53bb3affd9e 100644 --- a/google/cloud/resourcemanager/v3/tag_keys_connection.cc +++ b/google/cloud/resourcemanager/v3/tag_keys_connection.cc @@ -140,6 +140,11 @@ TagKeysConnection::TestIamPermissions( return Status(StatusCode::kUnimplemented, "not implemented"); } +StatusOr TagKeysConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeTagKeysConnection(Options options) { internal::CheckExpectedOptions TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/resourcemanager/v3/tag_keys_connection_idempotency_policy.cc b/google/cloud/resourcemanager/v3/tag_keys_connection_idempotency_policy.cc index 15cbf42369bfb..e9a3e52cd0e04 100644 --- a/google/cloud/resourcemanager/v3/tag_keys_connection_idempotency_policy.cc +++ b/google/cloud/resourcemanager/v3/tag_keys_connection_idempotency_policy.cc @@ -80,6 +80,11 @@ Idempotency TagKeysConnectionIdempotencyPolicy::TestIamPermissions( return Idempotency::kIdempotent; } +Idempotency TagKeysConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultTagKeysConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/resourcemanager/v3/tag_keys_connection_idempotency_policy.h b/google/cloud/resourcemanager/v3/tag_keys_connection_idempotency_policy.h index 3eaa06f74e760..846bd5a5b766e 100644 --- a/google/cloud/resourcemanager/v3/tag_keys_connection_idempotency_policy.h +++ b/google/cloud/resourcemanager/v3/tag_keys_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,9 @@ class TagKeysConnectionIdempotencyPolicy { virtual google::cloud::Idempotency TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/resourcemanager/v3/tag_values_client.cc b/google/cloud/resourcemanager/v3/tag_values_client.cc index 2e3d89b93624f..c0b77e820cd1b 100644 --- a/google/cloud/resourcemanager/v3/tag_values_client.cc +++ b/google/cloud/resourcemanager/v3/tag_values_client.cc @@ -290,6 +290,20 @@ TagValuesClient::TestIamPermissions( return connection_->TestIamPermissions(request); } +StatusOr TagValuesClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr TagValuesClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace resourcemanager_v3 } // namespace cloud diff --git a/google/cloud/resourcemanager/v3/tag_values_client.h b/google/cloud/resourcemanager/v3/tag_values_client.h index aea5ddb7086eb..ed28ee05ed6de 100644 --- a/google/cloud/resourcemanager/v3/tag_values_client.h +++ b/google/cloud/resourcemanager/v3/tag_values_client.h @@ -872,6 +872,66 @@ class TagValuesClient { google::iam::v1::TestIamPermissionsRequest const& request, Options opts = {}); + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/resourcemanager/v3/tag_values_connection.cc b/google/cloud/resourcemanager/v3/tag_values_connection.cc index 6c25cd2da89d1..35db1e6e1f52b 100644 --- a/google/cloud/resourcemanager/v3/tag_values_connection.cc +++ b/google/cloud/resourcemanager/v3/tag_values_connection.cc @@ -140,6 +140,11 @@ TagValuesConnection::TestIamPermissions( return Status(StatusCode::kUnimplemented, "not implemented"); } +StatusOr TagValuesConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeTagValuesConnection(Options options) { internal::CheckExpectedOptions TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/resourcemanager/v3/tag_values_connection_idempotency_policy.cc b/google/cloud/resourcemanager/v3/tag_values_connection_idempotency_policy.cc index 24b3f68eb6db9..a6562efdf7d97 100644 --- a/google/cloud/resourcemanager/v3/tag_values_connection_idempotency_policy.cc +++ b/google/cloud/resourcemanager/v3/tag_values_connection_idempotency_policy.cc @@ -80,6 +80,11 @@ Idempotency TagValuesConnectionIdempotencyPolicy::TestIamPermissions( return Idempotency::kIdempotent; } +Idempotency TagValuesConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultTagValuesConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/resourcemanager/v3/tag_values_connection_idempotency_policy.h b/google/cloud/resourcemanager/v3/tag_values_connection_idempotency_policy.h index 68cba154f0331..d2dddbd791db3 100644 --- a/google/cloud/resourcemanager/v3/tag_values_connection_idempotency_policy.h +++ b/google/cloud/resourcemanager/v3/tag_values_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,9 @@ class TagValuesConnectionIdempotencyPolicy { virtual google::cloud::Idempotency TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr 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_client.cc b/google/cloud/retail/v2/analytics_client.cc index 1d91d01f556b3..22250b3981f5d 100644 --- a/google/cloud/retail/v2/analytics_client.cc +++ b/google/cloud/retail/v2/analytics_client.cc @@ -56,6 +56,38 @@ AnalyticsServiceClient::ExportAnalyticsMetrics( return connection_->ExportAnalyticsMetrics(operation); } +StreamRange +AnalyticsServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +AnalyticsServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr AnalyticsServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr AnalyticsServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2 } // namespace cloud diff --git a/google/cloud/retail/v2/analytics_client.h b/google/cloud/retail/v2/analytics_client.h index cdcca85cdd427..146ef488e48ff 100644 --- a/google/cloud/retail/v2/analytics_client.h +++ b/google/cloud/retail/v2/analytics_client.h @@ -160,6 +160,158 @@ class AnalyticsServiceClient { ExportAnalyticsMetrics(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/retail/v2/analytics_connection.cc b/google/cloud/retail/v2/analytics_connection.cc index faa4c1f1c2352..c4e57eb884284 100644 --- a/google/cloud/retail/v2/analytics_connection.cc +++ b/google/cloud/retail/v2/analytics_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 @@ -61,6 +62,20 @@ AnalyticsServiceConnection::ExportAnalyticsMetrics( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +AnalyticsServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +AnalyticsServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeAnalyticsServiceConnection( Options options) { internal::CheckExpectedOptions #include @@ -198,6 +199,12 @@ class AnalyticsServiceConnection { virtual future< StatusOr> ExportAnalyticsMetrics(google::longrunning::Operation const& operation); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/retail/v2/analytics_connection_idempotency_policy.cc b/google/cloud/retail/v2/analytics_connection_idempotency_policy.cc index 52d2e5634bb94..bb519c4fb23b9 100644 --- a/google/cloud/retail/v2/analytics_connection_idempotency_policy.cc +++ b/google/cloud/retail/v2/analytics_connection_idempotency_policy.cc @@ -39,6 +39,16 @@ Idempotency AnalyticsServiceConnectionIdempotencyPolicy::ExportAnalyticsMetrics( return Idempotency::kNonIdempotent; } +Idempotency AnalyticsServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AnalyticsServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultAnalyticsServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/retail/v2/analytics_connection_idempotency_policy.h b/google/cloud/retail/v2/analytics_connection_idempotency_policy.h index e4f2a2594620f..a420c94f3564f 100644 --- a/google/cloud/retail/v2/analytics_connection_idempotency_policy.h +++ b/google/cloud/retail/v2/analytics_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -39,6 +40,12 @@ class AnalyticsServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ExportAnalyticsMetrics( google::cloud::retail::v2::ExportAnalyticsMetricsRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/retail/v2/catalog_client.cc b/google/cloud/retail/v2/catalog_client.cc index 8bc5f84fec40a..68659f81c27c5 100644 --- a/google/cloud/retail/v2/catalog_client.cc +++ b/google/cloud/retail/v2/catalog_client.cc @@ -194,6 +194,37 @@ CatalogServiceClient::ReplaceCatalogAttribute( return connection_->ReplaceCatalogAttribute(request); } +StreamRange +CatalogServiceClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +CatalogServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr CatalogServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr CatalogServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2 } // namespace cloud diff --git a/google/cloud/retail/v2/catalog_client.h b/google/cloud/retail/v2/catalog_client.h index ca0b3773922e2..a4194c3d6f660 100644 --- a/google/cloud/retail/v2/catalog_client.h +++ b/google/cloud/retail/v2/catalog_client.h @@ -801,6 +801,158 @@ class CatalogServiceClient { google::cloud::retail::v2::ReplaceCatalogAttributeRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/retail/v2/catalog_connection.cc b/google/cloud/retail/v2/catalog_connection.cc index ac216a8d7a4ef..a01e56f880e65 100644 --- a/google/cloud/retail/v2/catalog_connection.cc +++ b/google/cloud/retail/v2/catalog_connection.cc @@ -105,6 +105,19 @@ CatalogServiceConnection::ReplaceCatalogAttribute( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +CatalogServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr CatalogServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeCatalogServiceConnection( Options options) { internal::CheckExpectedOptions ReplaceCatalogAttribute( google::cloud::retail::v2::ReplaceCatalogAttributeRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/retail/v2/catalog_connection_idempotency_policy.cc b/google/cloud/retail/v2/catalog_connection_idempotency_policy.cc index 47b4d3069f464..a581315fc9bed 100644 --- a/google/cloud/retail/v2/catalog_connection_idempotency_policy.cc +++ b/google/cloud/retail/v2/catalog_connection_idempotency_policy.cc @@ -89,6 +89,16 @@ Idempotency CatalogServiceConnectionIdempotencyPolicy::ReplaceCatalogAttribute( return Idempotency::kNonIdempotent; } +Idempotency CatalogServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency CatalogServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultCatalogServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/retail/v2/catalog_connection_idempotency_policy.h b/google/cloud/retail/v2/catalog_connection_idempotency_policy.h index 9205ae1987563..295c6e92280d3 100644 --- a/google/cloud/retail/v2/catalog_connection_idempotency_policy.h +++ b/google/cloud/retail/v2/catalog_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 CatalogServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ReplaceCatalogAttribute( google::cloud::retail::v2::ReplaceCatalogAttributeRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/retail/v2/completion_client.cc b/google/cloud/retail/v2/completion_client.cc index f1001f9ffdc16..5f4dba8a857de 100644 --- a/google/cloud/retail/v2/completion_client.cc +++ b/google/cloud/retail/v2/completion_client.cc @@ -64,6 +64,38 @@ CompletionServiceClient::ImportCompletionData( return connection_->ImportCompletionData(operation); } +StreamRange +CompletionServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +CompletionServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr CompletionServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr CompletionServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2 } // namespace cloud diff --git a/google/cloud/retail/v2/completion_client.h b/google/cloud/retail/v2/completion_client.h index 373fd9b01c82c..74f4982dd79dc 100644 --- a/google/cloud/retail/v2/completion_client.h +++ b/google/cloud/retail/v2/completion_client.h @@ -201,6 +201,158 @@ class CompletionServiceClient { ImportCompletionData(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/retail/v2/completion_connection.cc b/google/cloud/retail/v2/completion_connection.cc index 3828095d0c594..06cc4a3715588 100644 --- a/google/cloud/retail/v2/completion_connection.cc +++ b/google/cloud/retail/v2/completion_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 @@ -66,6 +67,20 @@ CompletionServiceConnection::ImportCompletionData( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +CompletionServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +CompletionServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeCompletionServiceConnection( Options options) { internal::CheckExpectedOptions #include @@ -201,6 +202,12 @@ class CompletionServiceConnection { virtual future< StatusOr> ImportCompletionData(google::longrunning::Operation const& operation); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/retail/v2/completion_connection_idempotency_policy.cc b/google/cloud/retail/v2/completion_connection_idempotency_policy.cc index 9734c6a2d1df6..8b6533d3ade05 100644 --- a/google/cloud/retail/v2/completion_connection_idempotency_policy.cc +++ b/google/cloud/retail/v2/completion_connection_idempotency_policy.cc @@ -44,6 +44,16 @@ Idempotency CompletionServiceConnectionIdempotencyPolicy::ImportCompletionData( return Idempotency::kNonIdempotent; } +Idempotency CompletionServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency CompletionServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultCompletionServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/retail/v2/completion_connection_idempotency_policy.h b/google/cloud/retail/v2/completion_connection_idempotency_policy.h index cec2a0322bbd7..9ee3c7bb3c1c8 100644 --- a/google/cloud/retail/v2/completion_connection_idempotency_policy.h +++ b/google/cloud/retail/v2/completion_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 CompletionServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ImportCompletionData( google::cloud::retail::v2::ImportCompletionDataRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/retail/v2/control_client.cc b/google/cloud/retail/v2/control_client.cc index c978db544634e..ef4ec9add353c 100644 --- a/google/cloud/retail/v2/control_client.cc +++ b/google/cloud/retail/v2/control_client.cc @@ -116,6 +116,37 @@ ControlServiceClient::ListControls( return connection_->ListControls(std::move(request)); } +StreamRange +ControlServiceClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +ControlServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr ControlServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr ControlServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2 } // namespace cloud diff --git a/google/cloud/retail/v2/control_client.h b/google/cloud/retail/v2/control_client.h index b57ecf7d0847e..1fea4c2296a4a 100644 --- a/google/cloud/retail/v2/control_client.h +++ b/google/cloud/retail/v2/control_client.h @@ -423,6 +423,158 @@ class ControlServiceClient { google::cloud::retail::v2::ListControlsRequest request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/retail/v2/control_connection.cc b/google/cloud/retail/v2/control_connection.cc index a04a0a4348756..93edb4e6175ae 100644 --- a/google/cloud/retail/v2/control_connection.cc +++ b/google/cloud/retail/v2/control_connection.cc @@ -69,6 +69,19 @@ ControlServiceConnection::ListControls( StreamRange>(); } +StreamRange +ControlServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr ControlServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeControlServiceConnection( Options options) { internal::CheckExpectedOptions ListControls( google::cloud::retail::v2::ListControlsRequest request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/retail/v2/control_connection_idempotency_policy.cc b/google/cloud/retail/v2/control_connection_idempotency_policy.cc index a48701a561a1d..b28ddf23da3b7 100644 --- a/google/cloud/retail/v2/control_connection_idempotency_policy.cc +++ b/google/cloud/retail/v2/control_connection_idempotency_policy.cc @@ -59,6 +59,16 @@ Idempotency ControlServiceConnectionIdempotencyPolicy::ListControls( return Idempotency::kIdempotent; } +Idempotency ControlServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ControlServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultControlServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/retail/v2/control_connection_idempotency_policy.h b/google/cloud/retail/v2/control_connection_idempotency_policy.h index 2049e3988b4fd..cb21b38dfbcd6 100644 --- a/google/cloud/retail/v2/control_connection_idempotency_policy.h +++ b/google/cloud/retail/v2/control_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 ControlServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListControls( google::cloud::retail::v2::ListControlsRequest request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/retail/v2/internal/analytics_auth_decorator.cc b/google/cloud/retail/v2/internal/analytics_auth_decorator.cc index 4da47acde8526..affe81b6306de 100644 --- a/google/cloud/retail/v2/internal/analytics_auth_decorator.cc +++ b/google/cloud/retail/v2/internal/analytics_auth_decorator.cc @@ -60,6 +60,23 @@ AnalyticsServiceAuth::ExportAnalyticsMetrics( return child_->ExportAnalyticsMetrics(context, options, request); } +StatusOr +AnalyticsServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr AnalyticsServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + future> AnalyticsServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/retail/v2/internal/analytics_auth_decorator.h b/google/cloud/retail/v2/internal/analytics_auth_decorator.h index b69eba5114fb3..5a61f87e588ac 100644 --- a/google/cloud/retail/v2/internal/analytics_auth_decorator.h +++ b/google/cloud/retail/v2/internal/analytics_auth_decorator.h @@ -51,6 +51,14 @@ class AnalyticsServiceAuth : public AnalyticsServiceStub { google::cloud::retail::v2::ExportAnalyticsMetricsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/retail/v2/internal/analytics_connection_impl.cc b/google/cloud/retail/v2/internal/analytics_connection_impl.cc index b8db89400bf14..c42e2302f536f 100644 --- a/google/cloud/retail/v2/internal/analytics_connection_impl.cc +++ b/google/cloud/retail/v2/internal/analytics_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 @@ -156,6 +157,53 @@ AnalyticsServiceConnectionImpl::ExportAnalyticsMetrics( polling_policy(*current), __func__); } +StreamRange +AnalyticsServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +AnalyticsServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2_internal } // namespace cloud diff --git a/google/cloud/retail/v2/internal/analytics_connection_impl.h b/google/cloud/retail/v2/internal/analytics_connection_impl.h index e0fe1e56db04e..f3850cfe54dd9 100644 --- a/google/cloud/retail/v2/internal/analytics_connection_impl.h +++ b/google/cloud/retail/v2/internal/analytics_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,12 @@ class AnalyticsServiceConnectionImpl ExportAnalyticsMetrics( google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/retail/v2/internal/analytics_logging_decorator.cc b/google/cloud/retail/v2/internal/analytics_logging_decorator.cc index e6980da69c8df..b274ef35a799e 100644 --- a/google/cloud/retail/v2/internal/analytics_logging_decorator.cc +++ b/google/cloud/retail/v2/internal/analytics_logging_decorator.cc @@ -67,6 +67,29 @@ AnalyticsServiceLogging::ExportAnalyticsMetrics( context, options, request, __func__, tracing_options_); } +StatusOr +AnalyticsServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AnalyticsServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> AnalyticsServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/retail/v2/internal/analytics_logging_decorator.h b/google/cloud/retail/v2/internal/analytics_logging_decorator.h index cb593944d5b3a..f7001030afce7 100644 --- a/google/cloud/retail/v2/internal/analytics_logging_decorator.h +++ b/google/cloud/retail/v2/internal/analytics_logging_decorator.h @@ -51,6 +51,14 @@ class AnalyticsServiceLogging : public AnalyticsServiceStub { google::cloud::retail::v2::ExportAnalyticsMetricsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/retail/v2/internal/analytics_metadata_decorator.cc b/google/cloud/retail/v2/internal/analytics_metadata_decorator.cc index ee88ff90f5a25..f1dc53d7869af 100644 --- a/google/cloud/retail/v2/internal/analytics_metadata_decorator.cc +++ b/google/cloud/retail/v2/internal/analytics_metadata_decorator.cc @@ -65,6 +65,23 @@ AnalyticsServiceMetadata::ExportAnalyticsMetrics( return child_->ExportAnalyticsMetrics(context, options, request); } +StatusOr +AnalyticsServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr AnalyticsServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + future> AnalyticsServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/retail/v2/internal/analytics_metadata_decorator.h b/google/cloud/retail/v2/internal/analytics_metadata_decorator.h index 4cf74d9c0f0e7..957be1ccee40a 100644 --- a/google/cloud/retail/v2/internal/analytics_metadata_decorator.h +++ b/google/cloud/retail/v2/internal/analytics_metadata_decorator.h @@ -52,6 +52,14 @@ class AnalyticsServiceMetadata : public AnalyticsServiceStub { google::cloud::retail::v2::ExportAnalyticsMetricsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/retail/v2/internal/analytics_stub.cc b/google/cloud/retail/v2/internal/analytics_stub.cc index 7366749881adc..164127c027812 100644 --- a/google/cloud/retail/v2/internal/analytics_stub.cc +++ b/google/cloud/retail/v2/internal/analytics_stub.cc @@ -63,6 +63,30 @@ DefaultAnalyticsServiceStub::ExportAnalyticsMetrics( return response; } +StatusOr +DefaultAnalyticsServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAnalyticsServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultAnalyticsServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/retail/v2/internal/analytics_stub.h b/google/cloud/retail/v2/internal/analytics_stub.h index 7f670ff5c7382..43b9817fcd708 100644 --- a/google/cloud/retail/v2/internal/analytics_stub.h +++ b/google/cloud/retail/v2/internal/analytics_stub.h @@ -51,6 +51,14 @@ class AnalyticsServiceStub { google::cloud::retail::v2::ExportAnalyticsMetricsRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -70,9 +78,13 @@ class DefaultAnalyticsServiceStub : public AnalyticsServiceStub { std::unique_ptr< google::cloud::retail::v2::AnalyticsService::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} future> AsyncExportAnalyticsMetrics( google::cloud::CompletionQueue& cq, @@ -86,6 +98,14 @@ class DefaultAnalyticsServiceStub : public AnalyticsServiceStub { google::cloud::retail::v2::ExportAnalyticsMetricsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -101,6 +121,8 @@ class DefaultAnalyticsServiceStub : public AnalyticsServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/retail/v2/internal/analytics_stub_factory.cc b/google/cloud/retail/v2/internal/analytics_stub_factory.cc index d0bf20d713dcd..62dbb849e24ae 100644 --- a/google/cloud/retail/v2/internal/analytics_stub_factory.cc +++ b/google/cloud/retail/v2/internal/analytics_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 CreateDefaultAnalyticsServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::retail::v2::AnalyticsService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/retail/v2/internal/analytics_tracing_connection.cc b/google/cloud/retail/v2/internal/analytics_tracing_connection.cc index dbd2181288a7b..dec64c82d6df8 100644 --- a/google/cloud/retail/v2/internal/analytics_tracing_connection.cc +++ b/google/cloud/retail/v2/internal/analytics_tracing_connection.cc @@ -18,6 +18,7 @@ #include "google/cloud/retail/v2/internal/analytics_tracing_connection.h" #include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" #include #include @@ -63,6 +64,26 @@ AnalyticsServiceTracingConnection::ExportAnalyticsMetrics( child_->ExportAnalyticsMetrics(operation)); } +StreamRange +AnalyticsServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "retail_v2::AnalyticsServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AnalyticsServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("retail_v2::AnalyticsServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/retail/v2/internal/analytics_tracing_connection.h b/google/cloud/retail/v2/internal/analytics_tracing_connection.h index 0060721722b0d..25afd8ecc8be8 100644 --- a/google/cloud/retail/v2/internal/analytics_tracing_connection.h +++ b/google/cloud/retail/v2/internal/analytics_tracing_connection.h @@ -54,6 +54,12 @@ class AnalyticsServiceTracingConnection ExportAnalyticsMetrics( google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/retail/v2/internal/analytics_tracing_stub.cc b/google/cloud/retail/v2/internal/analytics_tracing_stub.cc index 9582ce2fd3063..cb90c10d665bc 100644 --- a/google/cloud/retail/v2/internal/analytics_tracing_stub.cc +++ b/google/cloud/retail/v2/internal/analytics_tracing_stub.cc @@ -60,6 +60,30 @@ AnalyticsServiceTracingStub::ExportAnalyticsMetrics( child_->ExportAnalyticsMetrics(context, options, request)); } +StatusOr +AnalyticsServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.retail.v2.AnalyticsService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +AnalyticsServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.retail.v2.AnalyticsService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + future> AnalyticsServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/retail/v2/internal/analytics_tracing_stub.h b/google/cloud/retail/v2/internal/analytics_tracing_stub.h index 02ce04acc80b6..ce09542c92e4e 100644 --- a/google/cloud/retail/v2/internal/analytics_tracing_stub.h +++ b/google/cloud/retail/v2/internal/analytics_tracing_stub.h @@ -51,6 +51,14 @@ class AnalyticsServiceTracingStub : public AnalyticsServiceStub { google::cloud::retail::v2::ExportAnalyticsMetricsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/retail/v2/internal/catalog_auth_decorator.cc b/google/cloud/retail/v2/internal/catalog_auth_decorator.cc index 430cc54aedb80..82278b51ca591 100644 --- a/google/cloud/retail/v2/internal/catalog_auth_decorator.cc +++ b/google/cloud/retail/v2/internal/catalog_auth_decorator.cc @@ -128,6 +128,23 @@ CatalogServiceAuth::ReplaceCatalogAttribute( return child_->ReplaceCatalogAttribute(context, options, request); } +StatusOr +CatalogServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr CatalogServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2_internal } // namespace cloud diff --git a/google/cloud/retail/v2/internal/catalog_auth_decorator.h b/google/cloud/retail/v2/internal/catalog_auth_decorator.h index c337a430e9528..fc3fb5901081c 100644 --- a/google/cloud/retail/v2/internal/catalog_auth_decorator.h +++ b/google/cloud/retail/v2/internal/catalog_auth_decorator.h @@ -91,6 +91,14 @@ class CatalogServiceAuth : public CatalogServiceStub { google::cloud::retail::v2::ReplaceCatalogAttributeRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/retail/v2/internal/catalog_connection_impl.cc b/google/cloud/retail/v2/internal/catalog_connection_impl.cc index c417e9b2b9dde..3d32daed150b8 100644 --- a/google/cloud/retail/v2/internal/catalog_connection_impl.cc +++ b/google/cloud/retail/v2/internal/catalog_connection_impl.cc @@ -241,6 +241,53 @@ CatalogServiceConnectionImpl::ReplaceCatalogAttribute( *current, request, __func__); } +StreamRange +CatalogServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +CatalogServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2_internal } // namespace cloud diff --git a/google/cloud/retail/v2/internal/catalog_connection_impl.h b/google/cloud/retail/v2/internal/catalog_connection_impl.h index 854d2705acb36..f19e673bc2073 100644 --- a/google/cloud/retail/v2/internal/catalog_connection_impl.h +++ b/google/cloud/retail/v2/internal/catalog_connection_impl.h @@ -91,6 +91,12 @@ class CatalogServiceConnectionImpl google::cloud::retail::v2::ReplaceCatalogAttributeRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/retail/v2/internal/catalog_logging_decorator.cc b/google/cloud/retail/v2/internal/catalog_logging_decorator.cc index ef9039dc9a014..fecde1f404acb 100644 --- a/google/cloud/retail/v2/internal/catalog_logging_decorator.cc +++ b/google/cloud/retail/v2/internal/catalog_logging_decorator.cc @@ -175,6 +175,29 @@ CatalogServiceLogging::ReplaceCatalogAttribute( context, options, request, __func__, tracing_options_); } +StatusOr +CatalogServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr CatalogServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2_internal } // namespace cloud diff --git a/google/cloud/retail/v2/internal/catalog_logging_decorator.h b/google/cloud/retail/v2/internal/catalog_logging_decorator.h index 56a8c02fd302c..aece2bd097ce2 100644 --- a/google/cloud/retail/v2/internal/catalog_logging_decorator.h +++ b/google/cloud/retail/v2/internal/catalog_logging_decorator.h @@ -91,6 +91,14 @@ class CatalogServiceLogging : public CatalogServiceStub { google::cloud::retail::v2::ReplaceCatalogAttributeRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/retail/v2/internal/catalog_metadata_decorator.cc b/google/cloud/retail/v2/internal/catalog_metadata_decorator.cc index 015d5d4007369..084db8aac336c 100644 --- a/google/cloud/retail/v2/internal/catalog_metadata_decorator.cc +++ b/google/cloud/retail/v2/internal/catalog_metadata_decorator.cc @@ -150,6 +150,23 @@ CatalogServiceMetadata::ReplaceCatalogAttribute( return child_->ReplaceCatalogAttribute(context, options, request); } +StatusOr +CatalogServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr CatalogServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + void CatalogServiceMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/retail/v2/internal/catalog_metadata_decorator.h b/google/cloud/retail/v2/internal/catalog_metadata_decorator.h index 6a5fb04f3e572..28191b7b8334a 100644 --- a/google/cloud/retail/v2/internal/catalog_metadata_decorator.h +++ b/google/cloud/retail/v2/internal/catalog_metadata_decorator.h @@ -91,6 +91,14 @@ class CatalogServiceMetadata : public CatalogServiceStub { google::cloud::retail::v2::ReplaceCatalogAttributeRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/retail/v2/internal/catalog_stub.cc b/google/cloud/retail/v2/internal/catalog_stub.cc index a42bee8fb7a87..b8030e2e05e48 100644 --- a/google/cloud/retail/v2/internal/catalog_stub.cc +++ b/google/cloud/retail/v2/internal/catalog_stub.cc @@ -165,6 +165,30 @@ DefaultCatalogServiceStub::ReplaceCatalogAttribute( return response; } +StatusOr +DefaultCatalogServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultCatalogServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2_internal } // namespace cloud diff --git a/google/cloud/retail/v2/internal/catalog_stub.h b/google/cloud/retail/v2/internal/catalog_stub.h index d9ab5a09dd119..0ba78e1291eb3 100644 --- a/google/cloud/retail/v2/internal/catalog_stub.h +++ b/google/cloud/retail/v2/internal/catalog_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -91,14 +92,25 @@ class CatalogServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::retail::v2::ReplaceCatalogAttributeRequest const& request) = 0; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; }; class DefaultCatalogServiceStub : public CatalogServiceStub { public: explicit DefaultCatalogServiceStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr ListCatalogs( grpc::ClientContext& context, Options const& options, @@ -153,9 +165,19 @@ class DefaultCatalogServiceStub : public CatalogServiceStub { google::cloud::retail::v2::ReplaceCatalogAttributeRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/retail/v2/internal/catalog_stub_factory.cc b/google/cloud/retail/v2/internal/catalog_stub_factory.cc index 20fe321fe660a..677624939cdaa 100644 --- a/google/cloud/retail/v2/internal/catalog_stub_factory.cc +++ b/google/cloud/retail/v2/internal/catalog_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 CreateDefaultCatalogServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::retail::v2::CatalogService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_stub)); if (auth->RequiresConfigureContext()) { stub = diff --git a/google/cloud/retail/v2/internal/catalog_tracing_connection.cc b/google/cloud/retail/v2/internal/catalog_tracing_connection.cc index 20fde04c95574..07dc1422cd252 100644 --- a/google/cloud/retail/v2/internal/catalog_tracing_connection.cc +++ b/google/cloud/retail/v2/internal/catalog_tracing_connection.cc @@ -133,6 +133,26 @@ CatalogServiceTracingConnection::ReplaceCatalogAttribute( return internal::EndSpan(*span, child_->ReplaceCatalogAttribute(request)); } +StreamRange +CatalogServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("retail_v2::CatalogServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +CatalogServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("retail_v2::CatalogServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/retail/v2/internal/catalog_tracing_connection.h b/google/cloud/retail/v2/internal/catalog_tracing_connection.h index 07d259f9ef04b..982f949fe6601 100644 --- a/google/cloud/retail/v2/internal/catalog_tracing_connection.h +++ b/google/cloud/retail/v2/internal/catalog_tracing_connection.h @@ -82,6 +82,12 @@ class CatalogServiceTracingConnection google::cloud::retail::v2::ReplaceCatalogAttributeRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/retail/v2/internal/catalog_tracing_stub.cc b/google/cloud/retail/v2/internal/catalog_tracing_stub.cc index d12941230e55d..d005340c6f377 100644 --- a/google/cloud/retail/v2/internal/catalog_tracing_stub.cc +++ b/google/cloud/retail/v2/internal/catalog_tracing_stub.cc @@ -167,6 +167,30 @@ CatalogServiceTracingStub::ReplaceCatalogAttribute( child_->ReplaceCatalogAttribute(context, options, request)); } +StatusOr +CatalogServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.retail.v2.CatalogService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +CatalogServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.retail.v2.CatalogService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeCatalogServiceTracingStub( diff --git a/google/cloud/retail/v2/internal/catalog_tracing_stub.h b/google/cloud/retail/v2/internal/catalog_tracing_stub.h index 362cf19319d63..e363b4b63e6c9 100644 --- a/google/cloud/retail/v2/internal/catalog_tracing_stub.h +++ b/google/cloud/retail/v2/internal/catalog_tracing_stub.h @@ -91,6 +91,14 @@ class CatalogServiceTracingStub : public CatalogServiceStub { google::cloud::retail::v2::ReplaceCatalogAttributeRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/retail/v2/internal/completion_auth_decorator.cc b/google/cloud/retail/v2/internal/completion_auth_decorator.cc index 7fd54c7c4ee53..7c3778a80f3f5 100644 --- a/google/cloud/retail/v2/internal/completion_auth_decorator.cc +++ b/google/cloud/retail/v2/internal/completion_auth_decorator.cc @@ -69,6 +69,23 @@ CompletionServiceAuth::ImportCompletionData( return child_->ImportCompletionData(context, options, request); } +StatusOr +CompletionServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr CompletionServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + future> CompletionServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/retail/v2/internal/completion_auth_decorator.h b/google/cloud/retail/v2/internal/completion_auth_decorator.h index 9bd7661a69f81..bc67fa4b66bbc 100644 --- a/google/cloud/retail/v2/internal/completion_auth_decorator.h +++ b/google/cloud/retail/v2/internal/completion_auth_decorator.h @@ -55,6 +55,14 @@ class CompletionServiceAuth : public CompletionServiceStub { google::cloud::retail::v2::ImportCompletionDataRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/retail/v2/internal/completion_connection_impl.cc b/google/cloud/retail/v2/internal/completion_connection_impl.cc index 3f8ee29817941..f42ce1b4002fb 100644 --- a/google/cloud/retail/v2/internal/completion_connection_impl.cc +++ b/google/cloud/retail/v2/internal/completion_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 @@ -172,6 +173,53 @@ CompletionServiceConnectionImpl::ImportCompletionData( polling_policy(*current), __func__); } +StreamRange +CompletionServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +CompletionServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2_internal } // namespace cloud diff --git a/google/cloud/retail/v2/internal/completion_connection_impl.h b/google/cloud/retail/v2/internal/completion_connection_impl.h index e8917e30ace19..5a190253b6a02 100644 --- a/google/cloud/retail/v2/internal/completion_connection_impl.h +++ b/google/cloud/retail/v2/internal/completion_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 @@ -68,6 +69,12 @@ class CompletionServiceConnectionImpl ImportCompletionData( google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/retail/v2/internal/completion_logging_decorator.cc b/google/cloud/retail/v2/internal/completion_logging_decorator.cc index a657383a59712..d9c7ef9ab1739 100644 --- a/google/cloud/retail/v2/internal/completion_logging_decorator.cc +++ b/google/cloud/retail/v2/internal/completion_logging_decorator.cc @@ -79,6 +79,29 @@ CompletionServiceLogging::ImportCompletionData( context, options, request, __func__, tracing_options_); } +StatusOr +CompletionServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr CompletionServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> CompletionServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/retail/v2/internal/completion_logging_decorator.h b/google/cloud/retail/v2/internal/completion_logging_decorator.h index f87ca0cc78b64..43d9ac70d97f9 100644 --- a/google/cloud/retail/v2/internal/completion_logging_decorator.h +++ b/google/cloud/retail/v2/internal/completion_logging_decorator.h @@ -55,6 +55,14 @@ class CompletionServiceLogging : public CompletionServiceStub { google::cloud::retail::v2::ImportCompletionDataRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/retail/v2/internal/completion_metadata_decorator.cc b/google/cloud/retail/v2/internal/completion_metadata_decorator.cc index dee7d607d9804..eeab54a998d29 100644 --- a/google/cloud/retail/v2/internal/completion_metadata_decorator.cc +++ b/google/cloud/retail/v2/internal/completion_metadata_decorator.cc @@ -74,6 +74,24 @@ CompletionServiceMetadata::ImportCompletionData( return child_->ImportCompletionData(context, options, request); } +StatusOr +CompletionServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +CompletionServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + future> CompletionServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/retail/v2/internal/completion_metadata_decorator.h b/google/cloud/retail/v2/internal/completion_metadata_decorator.h index 26b5ad0c206a7..c1c35c0913cf5 100644 --- a/google/cloud/retail/v2/internal/completion_metadata_decorator.h +++ b/google/cloud/retail/v2/internal/completion_metadata_decorator.h @@ -56,6 +56,14 @@ class CompletionServiceMetadata : public CompletionServiceStub { google::cloud::retail::v2::ImportCompletionDataRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/retail/v2/internal/completion_stub.cc b/google/cloud/retail/v2/internal/completion_stub.cc index 61fbda6c7acd2..6e02d44eccc5d 100644 --- a/google/cloud/retail/v2/internal/completion_stub.cc +++ b/google/cloud/retail/v2/internal/completion_stub.cc @@ -74,6 +74,30 @@ DefaultCompletionServiceStub::ImportCompletionData( return response; } +StatusOr +DefaultCompletionServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultCompletionServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultCompletionServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/retail/v2/internal/completion_stub.h b/google/cloud/retail/v2/internal/completion_stub.h index 60697cea8fad0..43081666af0c1 100644 --- a/google/cloud/retail/v2/internal/completion_stub.h +++ b/google/cloud/retail/v2/internal/completion_stub.h @@ -56,6 +56,14 @@ class CompletionServiceStub { google::cloud::retail::v2::ImportCompletionDataRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -75,9 +83,13 @@ class DefaultCompletionServiceStub : public CompletionServiceStub { std::unique_ptr< google::cloud::retail::v2::CompletionService::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr CompleteQuery( grpc::ClientContext& context, Options const& options, @@ -95,6 +107,14 @@ class DefaultCompletionServiceStub : public CompletionServiceStub { google::cloud::retail::v2::ImportCompletionDataRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -110,6 +130,8 @@ class DefaultCompletionServiceStub : public CompletionServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/retail/v2/internal/completion_stub_factory.cc b/google/cloud/retail/v2/internal/completion_stub_factory.cc index 2bfe16007a162..02495300a4cdf 100644 --- a/google/cloud/retail/v2/internal/completion_stub_factory.cc +++ b/google/cloud/retail/v2/internal/completion_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 CreateDefaultCompletionServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::retail::v2::CompletionService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/retail/v2/internal/completion_tracing_connection.cc b/google/cloud/retail/v2/internal/completion_tracing_connection.cc index 60d338c0571b3..85b2d00be4b4e 100644 --- a/google/cloud/retail/v2/internal/completion_tracing_connection.cc +++ b/google/cloud/retail/v2/internal/completion_tracing_connection.cc @@ -18,6 +18,7 @@ #include "google/cloud/retail/v2/internal/completion_tracing_connection.h" #include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" #include #include @@ -72,6 +73,26 @@ CompletionServiceTracingConnection::ImportCompletionData( child_->ImportCompletionData(operation)); } +StreamRange +CompletionServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "retail_v2::CompletionServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +CompletionServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "retail_v2::CompletionServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/retail/v2/internal/completion_tracing_connection.h b/google/cloud/retail/v2/internal/completion_tracing_connection.h index b261e9b0de38d..54cafe4ebc51c 100644 --- a/google/cloud/retail/v2/internal/completion_tracing_connection.h +++ b/google/cloud/retail/v2/internal/completion_tracing_connection.h @@ -57,6 +57,12 @@ class CompletionServiceTracingConnection ImportCompletionData( google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/retail/v2/internal/completion_tracing_stub.cc b/google/cloud/retail/v2/internal/completion_tracing_stub.cc index bc092c4149e1c..6339745e5c98c 100644 --- a/google/cloud/retail/v2/internal/completion_tracing_stub.cc +++ b/google/cloud/retail/v2/internal/completion_tracing_stub.cc @@ -71,6 +71,30 @@ CompletionServiceTracingStub::ImportCompletionData( context, *span, child_->ImportCompletionData(context, options, request)); } +StatusOr +CompletionServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.retail.v2.CompletionService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +CompletionServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.retail.v2.CompletionService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + future> CompletionServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/retail/v2/internal/completion_tracing_stub.h b/google/cloud/retail/v2/internal/completion_tracing_stub.h index 2c7b68e205092..d22e1cad9556b 100644 --- a/google/cloud/retail/v2/internal/completion_tracing_stub.h +++ b/google/cloud/retail/v2/internal/completion_tracing_stub.h @@ -55,6 +55,14 @@ class CompletionServiceTracingStub : public CompletionServiceStub { google::cloud::retail::v2::ImportCompletionDataRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/retail/v2/internal/control_auth_decorator.cc b/google/cloud/retail/v2/internal/control_auth_decorator.cc index d481eae8ab6ac..433f1809e716c 100644 --- a/google/cloud/retail/v2/internal/control_auth_decorator.cc +++ b/google/cloud/retail/v2/internal/control_auth_decorator.cc @@ -72,6 +72,23 @@ ControlServiceAuth::ListControls( return child_->ListControls(context, options, request); } +StatusOr +ControlServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr ControlServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2_internal } // namespace cloud diff --git a/google/cloud/retail/v2/internal/control_auth_decorator.h b/google/cloud/retail/v2/internal/control_auth_decorator.h index 867c23a5f0b2f..e488afed2b742 100644 --- a/google/cloud/retail/v2/internal/control_auth_decorator.h +++ b/google/cloud/retail/v2/internal/control_auth_decorator.h @@ -58,6 +58,14 @@ class ControlServiceAuth : public ControlServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::retail::v2::ListControlsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/retail/v2/internal/control_connection_impl.cc b/google/cloud/retail/v2/internal/control_connection_impl.cc index dc9697f9a4289..9df523a4df2d9 100644 --- a/google/cloud/retail/v2/internal/control_connection_impl.cc +++ b/google/cloud/retail/v2/internal/control_connection_impl.cc @@ -148,6 +148,53 @@ ControlServiceConnectionImpl::ListControls( }); } +StreamRange +ControlServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ControlServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2_internal } // namespace cloud diff --git a/google/cloud/retail/v2/internal/control_connection_impl.h b/google/cloud/retail/v2/internal/control_connection_impl.h index 3f8230acd1153..dd6072fff2cfc 100644 --- a/google/cloud/retail/v2/internal/control_connection_impl.h +++ b/google/cloud/retail/v2/internal/control_connection_impl.h @@ -64,6 +64,12 @@ class ControlServiceConnectionImpl StreamRange ListControls( google::cloud::retail::v2::ListControlsRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/retail/v2/internal/control_logging_decorator.cc b/google/cloud/retail/v2/internal/control_logging_decorator.cc index 68014c42db4f1..ac3fcfd2e8b0b 100644 --- a/google/cloud/retail/v2/internal/control_logging_decorator.cc +++ b/google/cloud/retail/v2/internal/control_logging_decorator.cc @@ -93,6 +93,29 @@ ControlServiceLogging::ListControls( context, options, request, __func__, tracing_options_); } +StatusOr +ControlServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ControlServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2_internal } // namespace cloud diff --git a/google/cloud/retail/v2/internal/control_logging_decorator.h b/google/cloud/retail/v2/internal/control_logging_decorator.h index a493eaf57ae26..0c4430a63ad31 100644 --- a/google/cloud/retail/v2/internal/control_logging_decorator.h +++ b/google/cloud/retail/v2/internal/control_logging_decorator.h @@ -58,6 +58,14 @@ class ControlServiceLogging : public ControlServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::retail::v2::ListControlsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/retail/v2/internal/control_metadata_decorator.cc b/google/cloud/retail/v2/internal/control_metadata_decorator.cc index 74979562358cc..27606d7008b18 100644 --- a/google/cloud/retail/v2/internal/control_metadata_decorator.cc +++ b/google/cloud/retail/v2/internal/control_metadata_decorator.cc @@ -88,6 +88,23 @@ ControlServiceMetadata::ListControls( return child_->ListControls(context, options, request); } +StatusOr +ControlServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr ControlServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + void ControlServiceMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/retail/v2/internal/control_metadata_decorator.h b/google/cloud/retail/v2/internal/control_metadata_decorator.h index 21dff204dac9c..5d94dbe661d00 100644 --- a/google/cloud/retail/v2/internal/control_metadata_decorator.h +++ b/google/cloud/retail/v2/internal/control_metadata_decorator.h @@ -58,6 +58,14 @@ class ControlServiceMetadata : public ControlServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::retail::v2::ListControlsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/retail/v2/internal/control_stub.cc b/google/cloud/retail/v2/internal/control_stub.cc index a9f8cc6c3d0bb..123c856b0ecea 100644 --- a/google/cloud/retail/v2/internal/control_stub.cc +++ b/google/cloud/retail/v2/internal/control_stub.cc @@ -89,6 +89,30 @@ DefaultControlServiceStub::ListControls( return response; } +StatusOr +DefaultControlServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultControlServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2_internal } // namespace cloud diff --git a/google/cloud/retail/v2/internal/control_stub.h b/google/cloud/retail/v2/internal/control_stub.h index a5fb0e876c702..f11aec9164a00 100644 --- a/google/cloud/retail/v2/internal/control_stub.h +++ b/google/cloud/retail/v2/internal/control_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -55,14 +56,25 @@ class ControlServiceStub { ListControls( grpc::ClientContext& context, Options const& options, google::cloud::retail::v2::ListControlsRequest const& request) = 0; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; }; class DefaultControlServiceStub : public ControlServiceStub { public: explicit DefaultControlServiceStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr CreateControl( grpc::ClientContext& context, Options const& options, @@ -84,9 +96,19 @@ class DefaultControlServiceStub : public ControlServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::retail::v2::ListControlsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/retail/v2/internal/control_stub_factory.cc b/google/cloud/retail/v2/internal/control_stub_factory.cc index 5d6ad6b3d4486..f3bf78bbf76bc 100644 --- a/google/cloud/retail/v2/internal/control_stub_factory.cc +++ b/google/cloud/retail/v2/internal/control_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 CreateDefaultControlServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::retail::v2::ControlService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_stub)); if (auth->RequiresConfigureContext()) { stub = diff --git a/google/cloud/retail/v2/internal/control_tracing_connection.cc b/google/cloud/retail/v2/internal/control_tracing_connection.cc index 8823f5835d0d3..f80cb239665bc 100644 --- a/google/cloud/retail/v2/internal/control_tracing_connection.cc +++ b/google/cloud/retail/v2/internal/control_tracing_connection.cc @@ -79,6 +79,26 @@ ControlServiceTracingConnection::ListControls( std::move(span), std::move(sr)); } +StreamRange +ControlServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("retail_v2::ControlServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ControlServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("retail_v2::ControlServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/retail/v2/internal/control_tracing_connection.h b/google/cloud/retail/v2/internal/control_tracing_connection.h index 7832e7652bf57..f5a16af6cd8ab 100644 --- a/google/cloud/retail/v2/internal/control_tracing_connection.h +++ b/google/cloud/retail/v2/internal/control_tracing_connection.h @@ -55,6 +55,12 @@ class ControlServiceTracingConnection StreamRange ListControls( google::cloud::retail::v2::ListControlsRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/retail/v2/internal/control_tracing_stub.cc b/google/cloud/retail/v2/internal/control_tracing_stub.cc index 40573aaf7214d..bf87097942f55 100644 --- a/google/cloud/retail/v2/internal/control_tracing_stub.cc +++ b/google/cloud/retail/v2/internal/control_tracing_stub.cc @@ -91,6 +91,30 @@ ControlServiceTracingStub::ListControls( child_->ListControls(context, options, request)); } +StatusOr +ControlServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.retail.v2.ControlService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +ControlServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.retail.v2.ControlService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeControlServiceTracingStub( diff --git a/google/cloud/retail/v2/internal/control_tracing_stub.h b/google/cloud/retail/v2/internal/control_tracing_stub.h index 5cddb933b5c09..08f7d3430f9a9 100644 --- a/google/cloud/retail/v2/internal/control_tracing_stub.h +++ b/google/cloud/retail/v2/internal/control_tracing_stub.h @@ -58,6 +58,14 @@ class ControlServiceTracingStub : public ControlServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::retail::v2::ListControlsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/retail/v2/internal/model_auth_decorator.cc b/google/cloud/retail/v2/internal/model_auth_decorator.cc index f178939ec3db0..ca3fc84360188 100644 --- a/google/cloud/retail/v2/internal/model_auth_decorator.cc +++ b/google/cloud/retail/v2/internal/model_auth_decorator.cc @@ -136,6 +136,23 @@ StatusOr ModelServiceAuth::TuneModel( return child_->TuneModel(context, options, request); } +StatusOr +ModelServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr ModelServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + future> ModelServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/retail/v2/internal/model_auth_decorator.h b/google/cloud/retail/v2/internal/model_auth_decorator.h index d14d1c9f58616..5bbdc5393b120 100644 --- a/google/cloud/retail/v2/internal/model_auth_decorator.h +++ b/google/cloud/retail/v2/internal/model_auth_decorator.h @@ -83,6 +83,14 @@ class ModelServiceAuth : public ModelServiceStub { grpc::ClientContext& context, Options options, google::cloud::retail::v2::TuneModelRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/retail/v2/internal/model_connection_impl.cc b/google/cloud/retail/v2/internal/model_connection_impl.cc index 56257ac519a52..bc9200fc27f5b 100644 --- a/google/cloud/retail/v2/internal/model_connection_impl.cc +++ b/google/cloud/retail/v2/internal/model_connection_impl.cc @@ -341,6 +341,53 @@ ModelServiceConnectionImpl::TuneModel( polling_policy(*current), __func__); } +StreamRange +ModelServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ModelServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2_internal } // namespace cloud diff --git a/google/cloud/retail/v2/internal/model_connection_impl.h b/google/cloud/retail/v2/internal/model_connection_impl.h index 2309eb0f0d0c7..09ec76f6d140e 100644 --- a/google/cloud/retail/v2/internal/model_connection_impl.h +++ b/google/cloud/retail/v2/internal/model_connection_impl.h @@ -89,6 +89,12 @@ class ModelServiceConnectionImpl : public retail_v2::ModelServiceConnection { future> TuneModel( google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/retail/v2/internal/model_logging_decorator.cc b/google/cloud/retail/v2/internal/model_logging_decorator.cc index 2e267c7d9f8d5..f106027d06305 100644 --- a/google/cloud/retail/v2/internal/model_logging_decorator.cc +++ b/google/cloud/retail/v2/internal/model_logging_decorator.cc @@ -160,6 +160,29 @@ StatusOr ModelServiceLogging::TuneModel( context, options, request, __func__, tracing_options_); } +StatusOr +ModelServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ModelServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> ModelServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/retail/v2/internal/model_logging_decorator.h b/google/cloud/retail/v2/internal/model_logging_decorator.h index e207a00f0b44a..d6b437ab0a208 100644 --- a/google/cloud/retail/v2/internal/model_logging_decorator.h +++ b/google/cloud/retail/v2/internal/model_logging_decorator.h @@ -83,6 +83,14 @@ class ModelServiceLogging : public ModelServiceStub { grpc::ClientContext& context, Options options, google::cloud::retail::v2::TuneModelRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/retail/v2/internal/model_metadata_decorator.cc b/google/cloud/retail/v2/internal/model_metadata_decorator.cc index 7c95c464e8bc8..489219e1fd1e1 100644 --- a/google/cloud/retail/v2/internal/model_metadata_decorator.cc +++ b/google/cloud/retail/v2/internal/model_metadata_decorator.cc @@ -134,6 +134,23 @@ StatusOr ModelServiceMetadata::TuneModel( return child_->TuneModel(context, options, request); } +StatusOr +ModelServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr ModelServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + future> ModelServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/retail/v2/internal/model_metadata_decorator.h b/google/cloud/retail/v2/internal/model_metadata_decorator.h index 61e369632f22b..c842133073614 100644 --- a/google/cloud/retail/v2/internal/model_metadata_decorator.h +++ b/google/cloud/retail/v2/internal/model_metadata_decorator.h @@ -83,6 +83,14 @@ class ModelServiceMetadata : public ModelServiceStub { grpc::ClientContext& context, Options options, google::cloud::retail::v2::TuneModelRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/retail/v2/internal/model_stub.cc b/google/cloud/retail/v2/internal/model_stub.cc index e508ab4fd91ef..207249a34f8a1 100644 --- a/google/cloud/retail/v2/internal/model_stub.cc +++ b/google/cloud/retail/v2/internal/model_stub.cc @@ -155,6 +155,29 @@ StatusOr DefaultModelServiceStub::TuneModel( return response; } +StatusOr +DefaultModelServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultModelServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&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/retail/v2/internal/model_stub.h b/google/cloud/retail/v2/internal/model_stub.h index 49c984fa709d8..a1c45fac7255d 100644 --- a/google/cloud/retail/v2/internal/model_stub.h +++ b/google/cloud/retail/v2/internal/model_stub.h @@ -82,6 +82,14 @@ class ModelServiceStub { grpc::ClientContext& context, Options options, google::cloud::retail::v2::TuneModelRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -100,9 +108,13 @@ class DefaultModelServiceStub : public ModelServiceStub { DefaultModelServiceStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateModel( google::cloud::CompletionQueue& cq, @@ -148,6 +160,14 @@ class DefaultModelServiceStub : public ModelServiceStub { grpc::ClientContext& context, Options options, google::cloud::retail::v2::TuneModelRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -163,6 +183,8 @@ class DefaultModelServiceStub : public ModelServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/retail/v2/internal/model_stub_factory.cc b/google/cloud/retail/v2/internal/model_stub_factory.cc index 1c9b1abd08ff4..ffdbff3b66a72 100644 --- a/google/cloud/retail/v2/internal/model_stub_factory.cc +++ b/google/cloud/retail/v2/internal/model_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 CreateDefaultModelServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::retail::v2::ModelService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/retail/v2/internal/model_tracing_connection.cc b/google/cloud/retail/v2/internal/model_tracing_connection.cc index 7efec5a7cdd9f..1b90880f201b9 100644 --- a/google/cloud/retail/v2/internal/model_tracing_connection.cc +++ b/google/cloud/retail/v2/internal/model_tracing_connection.cc @@ -141,6 +141,26 @@ ModelServiceTracingConnection::TuneModel( return internal::EndSpan(std::move(span), child_->TuneModel(operation)); } +StreamRange +ModelServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("retail_v2::ModelServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ModelServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("retail_v2::ModelServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/retail/v2/internal/model_tracing_connection.h b/google/cloud/retail/v2/internal/model_tracing_connection.h index 62d4f34b47dd7..087c43e928c84 100644 --- a/google/cloud/retail/v2/internal/model_tracing_connection.h +++ b/google/cloud/retail/v2/internal/model_tracing_connection.h @@ -77,6 +77,12 @@ class ModelServiceTracingConnection : public retail_v2::ModelServiceConnection { future> TuneModel( google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/retail/v2/internal/model_tracing_stub.cc b/google/cloud/retail/v2/internal/model_tracing_stub.cc index 6954a8afe2f1b..16790e6de8997 100644 --- a/google/cloud/retail/v2/internal/model_tracing_stub.cc +++ b/google/cloud/retail/v2/internal/model_tracing_stub.cc @@ -149,6 +149,29 @@ StatusOr ModelServiceTracingStub::TuneModel( child_->TuneModel(context, options, request)); } +StatusOr +ModelServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.retail.v2.ModelService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr ModelServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.retail.v2.ModelService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + future> ModelServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/retail/v2/internal/model_tracing_stub.h b/google/cloud/retail/v2/internal/model_tracing_stub.h index c921e891827f4..cff1499430674 100644 --- a/google/cloud/retail/v2/internal/model_tracing_stub.h +++ b/google/cloud/retail/v2/internal/model_tracing_stub.h @@ -82,6 +82,14 @@ class ModelServiceTracingStub : public ModelServiceStub { grpc::ClientContext& context, Options options, google::cloud::retail::v2::TuneModelRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/retail/v2/internal/prediction_auth_decorator.cc b/google/cloud/retail/v2/internal/prediction_auth_decorator.cc index 830e4c1e31068..e826024e289d1 100644 --- a/google/cloud/retail/v2/internal/prediction_auth_decorator.cc +++ b/google/cloud/retail/v2/internal/prediction_auth_decorator.cc @@ -40,6 +40,23 @@ PredictionServiceAuth::Predict( return child_->Predict(context, options, request); } +StatusOr +PredictionServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr PredictionServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2_internal } // namespace cloud diff --git a/google/cloud/retail/v2/internal/prediction_auth_decorator.h b/google/cloud/retail/v2/internal/prediction_auth_decorator.h index 81c4eeee6b975..d2a1d721b37b5 100644 --- a/google/cloud/retail/v2/internal/prediction_auth_decorator.h +++ b/google/cloud/retail/v2/internal/prediction_auth_decorator.h @@ -42,6 +42,14 @@ class PredictionServiceAuth : public PredictionServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::retail::v2::PredictRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/retail/v2/internal/prediction_connection_impl.cc b/google/cloud/retail/v2/internal/prediction_connection_impl.cc index 778bb786c9e0f..cce73f037c966 100644 --- a/google/cloud/retail/v2/internal/prediction_connection_impl.cc +++ b/google/cloud/retail/v2/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/retry_loop.h" #include #include @@ -73,6 +74,53 @@ PredictionServiceConnectionImpl::Predict( *current, request, __func__); } +StreamRange +PredictionServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +PredictionServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2_internal } // namespace cloud diff --git a/google/cloud/retail/v2/internal/prediction_connection_impl.h b/google/cloud/retail/v2/internal/prediction_connection_impl.h index 2ca693fde3caf..8dabebfe2e7d4 100644 --- a/google/cloud/retail/v2/internal/prediction_connection_impl.h +++ b/google/cloud/retail/v2/internal/prediction_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 @@ -51,6 +52,12 @@ class PredictionServiceConnectionImpl StatusOr Predict( google::cloud::retail::v2::PredictRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/retail/v2/internal/prediction_logging_decorator.cc b/google/cloud/retail/v2/internal/prediction_logging_decorator.cc index 2bd441d86f1c6..0fcaba0028139 100644 --- a/google/cloud/retail/v2/internal/prediction_logging_decorator.cc +++ b/google/cloud/retail/v2/internal/prediction_logging_decorator.cc @@ -47,6 +47,29 @@ PredictionServiceLogging::Predict( context, options, request, __func__, tracing_options_); } +StatusOr +PredictionServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr PredictionServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2_internal } // namespace cloud diff --git a/google/cloud/retail/v2/internal/prediction_logging_decorator.h b/google/cloud/retail/v2/internal/prediction_logging_decorator.h index 771beab74bf50..b107d8fd965e9 100644 --- a/google/cloud/retail/v2/internal/prediction_logging_decorator.h +++ b/google/cloud/retail/v2/internal/prediction_logging_decorator.h @@ -42,6 +42,14 @@ class PredictionServiceLogging : public PredictionServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::retail::v2::PredictRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/retail/v2/internal/prediction_metadata_decorator.cc b/google/cloud/retail/v2/internal/prediction_metadata_decorator.cc index bdaa5466cca64..17270b053fea2 100644 --- a/google/cloud/retail/v2/internal/prediction_metadata_decorator.cc +++ b/google/cloud/retail/v2/internal/prediction_metadata_decorator.cc @@ -54,6 +54,24 @@ PredictionServiceMetadata::Predict( return child_->Predict(context, options, request); } +StatusOr +PredictionServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +PredictionServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + void PredictionServiceMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/retail/v2/internal/prediction_metadata_decorator.h b/google/cloud/retail/v2/internal/prediction_metadata_decorator.h index 7f054b2e15045..36286acaed459 100644 --- a/google/cloud/retail/v2/internal/prediction_metadata_decorator.h +++ b/google/cloud/retail/v2/internal/prediction_metadata_decorator.h @@ -43,6 +43,14 @@ class PredictionServiceMetadata : public PredictionServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::retail::v2::PredictRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/retail/v2/internal/prediction_stub.cc b/google/cloud/retail/v2/internal/prediction_stub.cc index c3f4b1baac9f6..e15e31971bd04 100644 --- a/google/cloud/retail/v2/internal/prediction_stub.cc +++ b/google/cloud/retail/v2/internal/prediction_stub.cc @@ -42,6 +42,30 @@ DefaultPredictionServiceStub::Predict( return response; } +StatusOr +DefaultPredictionServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPredictionServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2_internal } // namespace cloud diff --git a/google/cloud/retail/v2/internal/prediction_stub.h b/google/cloud/retail/v2/internal/prediction_stub.h index 6995ef92c3c54..a06c80cacc5e0 100644 --- a/google/cloud/retail/v2/internal/prediction_stub.h +++ b/google/cloud/retail/v2/internal/prediction_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -38,6 +39,14 @@ class PredictionServiceStub { virtual StatusOr Predict( grpc::ClientContext& context, Options const& options, google::cloud::retail::v2::PredictRequest const& request) = 0; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; }; class DefaultPredictionServiceStub : public PredictionServiceStub { @@ -45,16 +54,29 @@ class DefaultPredictionServiceStub : public PredictionServiceStub { explicit DefaultPredictionServiceStub( std::unique_ptr< google::cloud::retail::v2::PredictionService::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr Predict( grpc::ClientContext& context, Options const& options, google::cloud::retail::v2::PredictRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/retail/v2/internal/prediction_stub_factory.cc b/google/cloud/retail/v2/internal/prediction_stub_factory.cc index db0ca6b90c24a..861ddfcf44b5c 100644 --- a/google/cloud/retail/v2/internal/prediction_stub_factory.cc +++ b/google/cloud/retail/v2/internal/prediction_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 CreateDefaultPredictionServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::retail::v2::PredictionService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_operations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/retail/v2/internal/prediction_tracing_connection.cc b/google/cloud/retail/v2/internal/prediction_tracing_connection.cc index ba7c2b68b12cc..337f806685499 100644 --- a/google/cloud/retail/v2/internal/prediction_tracing_connection.cc +++ b/google/cloud/retail/v2/internal/prediction_tracing_connection.cc @@ -18,6 +18,7 @@ #include "google/cloud/retail/v2/internal/prediction_tracing_connection.h" #include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" #include #include @@ -41,6 +42,26 @@ PredictionServiceTracingConnection::Predict( return internal::EndSpan(*span, child_->Predict(request)); } +StreamRange +PredictionServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "retail_v2::PredictionServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +PredictionServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "retail_v2::PredictionServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/retail/v2/internal/prediction_tracing_connection.h b/google/cloud/retail/v2/internal/prediction_tracing_connection.h index f720ab91273dc..5381b94618f7f 100644 --- a/google/cloud/retail/v2/internal/prediction_tracing_connection.h +++ b/google/cloud/retail/v2/internal/prediction_tracing_connection.h @@ -43,6 +43,12 @@ class PredictionServiceTracingConnection StatusOr Predict( google::cloud::retail::v2::PredictRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/retail/v2/internal/prediction_tracing_stub.cc b/google/cloud/retail/v2/internal/prediction_tracing_stub.cc index 1e073b99ff25d..3a7139fbffd9b 100644 --- a/google/cloud/retail/v2/internal/prediction_tracing_stub.cc +++ b/google/cloud/retail/v2/internal/prediction_tracing_stub.cc @@ -44,6 +44,30 @@ PredictionServiceTracingStub::Predict( child_->Predict(context, options, request)); } +StatusOr +PredictionServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.retail.v2.PredictionService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +PredictionServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.retail.v2.PredictionService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakePredictionServiceTracingStub( diff --git a/google/cloud/retail/v2/internal/prediction_tracing_stub.h b/google/cloud/retail/v2/internal/prediction_tracing_stub.h index 5f9f58e8808cd..285f553badd1f 100644 --- a/google/cloud/retail/v2/internal/prediction_tracing_stub.h +++ b/google/cloud/retail/v2/internal/prediction_tracing_stub.h @@ -43,6 +43,14 @@ class PredictionServiceTracingStub : public PredictionServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::retail::v2::PredictRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/retail/v2/internal/product_auth_decorator.cc b/google/cloud/retail/v2/internal/product_auth_decorator.cc index 77f00ca304c09..d1428136c6931 100644 --- a/google/cloud/retail/v2/internal/product_auth_decorator.cc +++ b/google/cloud/retail/v2/internal/product_auth_decorator.cc @@ -272,6 +272,23 @@ ProductServiceAuth::RemoveLocalInventories( return child_->RemoveLocalInventories(context, options, request); } +StatusOr +ProductServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr ProductServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + future> ProductServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/retail/v2/internal/product_auth_decorator.h b/google/cloud/retail/v2/internal/product_auth_decorator.h index 011482ee14310..06918c8d0b5ce 100644 --- a/google/cloud/retail/v2/internal/product_auth_decorator.h +++ b/google/cloud/retail/v2/internal/product_auth_decorator.h @@ -137,6 +137,14 @@ class ProductServiceAuth : public ProductServiceStub { google::cloud::retail::v2::RemoveLocalInventoriesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/retail/v2/internal/product_connection_impl.cc b/google/cloud/retail/v2/internal/product_connection_impl.cc index e2a731d70a355..31206e16846e5 100644 --- a/google/cloud/retail/v2/internal/product_connection_impl.cc +++ b/google/cloud/retail/v2/internal/product_connection_impl.cc @@ -801,6 +801,53 @@ ProductServiceConnectionImpl::RemoveLocalInventories( polling_policy(*current), __func__); } +StreamRange +ProductServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ProductServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2_internal } // namespace cloud diff --git a/google/cloud/retail/v2/internal/product_connection_impl.h b/google/cloud/retail/v2/internal/product_connection_impl.h index c8cc2ab28fe85..5206f22185a84 100644 --- a/google/cloud/retail/v2/internal/product_connection_impl.h +++ b/google/cloud/retail/v2/internal/product_connection_impl.h @@ -155,6 +155,12 @@ class ProductServiceConnectionImpl RemoveLocalInventories( google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/retail/v2/internal/product_logging_decorator.cc b/google/cloud/retail/v2/internal/product_logging_decorator.cc index 4206f95625187..95d9bfa7db0f9 100644 --- a/google/cloud/retail/v2/internal/product_logging_decorator.cc +++ b/google/cloud/retail/v2/internal/product_logging_decorator.cc @@ -308,6 +308,29 @@ ProductServiceLogging::RemoveLocalInventories( context, options, request, __func__, tracing_options_); } +StatusOr +ProductServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ProductServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> ProductServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/retail/v2/internal/product_logging_decorator.h b/google/cloud/retail/v2/internal/product_logging_decorator.h index 01cc98b721865..55dd8d52b5fdc 100644 --- a/google/cloud/retail/v2/internal/product_logging_decorator.h +++ b/google/cloud/retail/v2/internal/product_logging_decorator.h @@ -137,6 +137,14 @@ class ProductServiceLogging : public ProductServiceStub { google::cloud::retail::v2::RemoveLocalInventoriesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/retail/v2/internal/product_metadata_decorator.cc b/google/cloud/retail/v2/internal/product_metadata_decorator.cc index 93978a9088db8..700a496a24cd0 100644 --- a/google/cloud/retail/v2/internal/product_metadata_decorator.cc +++ b/google/cloud/retail/v2/internal/product_metadata_decorator.cc @@ -234,6 +234,23 @@ ProductServiceMetadata::RemoveLocalInventories( return child_->RemoveLocalInventories(context, options, request); } +StatusOr +ProductServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr ProductServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + future> ProductServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/retail/v2/internal/product_metadata_decorator.h b/google/cloud/retail/v2/internal/product_metadata_decorator.h index eaef7ada28a40..844862c8da654 100644 --- a/google/cloud/retail/v2/internal/product_metadata_decorator.h +++ b/google/cloud/retail/v2/internal/product_metadata_decorator.h @@ -137,6 +137,14 @@ class ProductServiceMetadata : public ProductServiceStub { google::cloud::retail::v2::RemoveLocalInventoriesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/retail/v2/internal/product_stub.cc b/google/cloud/retail/v2/internal/product_stub.cc index c5acd306bedb9..1d0e6534530b6 100644 --- a/google/cloud/retail/v2/internal/product_stub.cc +++ b/google/cloud/retail/v2/internal/product_stub.cc @@ -306,6 +306,30 @@ DefaultProductServiceStub::RemoveLocalInventories( return response; } +StatusOr +DefaultProductServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultProductServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultProductServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/retail/v2/internal/product_stub.h b/google/cloud/retail/v2/internal/product_stub.h index 5bb3df2c55563..a3ba4fdea13d7 100644 --- a/google/cloud/retail/v2/internal/product_stub.h +++ b/google/cloud/retail/v2/internal/product_stub.h @@ -139,6 +139,14 @@ class ProductServiceStub { google::cloud::retail::v2::RemoveLocalInventoriesRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -157,9 +165,13 @@ class DefaultProductServiceStub : public ProductServiceStub { DefaultProductServiceStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr CreateProduct( grpc::ClientContext& context, Options const& options, @@ -259,6 +271,14 @@ class DefaultProductServiceStub : public ProductServiceStub { google::cloud::retail::v2::RemoveLocalInventoriesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -274,6 +294,8 @@ class DefaultProductServiceStub : public ProductServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/retail/v2/internal/product_stub_factory.cc b/google/cloud/retail/v2/internal/product_stub_factory.cc index c1e88c6c1df1d..c21e8ddfcf9c1 100644 --- a/google/cloud/retail/v2/internal/product_stub_factory.cc +++ b/google/cloud/retail/v2/internal/product_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 CreateDefaultProductServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::retail::v2::ProductService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/retail/v2/internal/product_tracing_connection.cc b/google/cloud/retail/v2/internal/product_tracing_connection.cc index 57d60fa270ffe..7f6aece8b6f3d 100644 --- a/google/cloud/retail/v2/internal/product_tracing_connection.cc +++ b/google/cloud/retail/v2/internal/product_tracing_connection.cc @@ -287,6 +287,26 @@ ProductServiceTracingConnection::RemoveLocalInventories( child_->RemoveLocalInventories(operation)); } +StreamRange +ProductServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("retail_v2::ProductServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ProductServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("retail_v2::ProductServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/retail/v2/internal/product_tracing_connection.h b/google/cloud/retail/v2/internal/product_tracing_connection.h index 2f03943851db2..627ad0b426de6 100644 --- a/google/cloud/retail/v2/internal/product_tracing_connection.h +++ b/google/cloud/retail/v2/internal/product_tracing_connection.h @@ -143,6 +143,12 @@ class ProductServiceTracingConnection RemoveLocalInventories( google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/retail/v2/internal/product_tracing_stub.cc b/google/cloud/retail/v2/internal/product_tracing_stub.cc index 7306cd0725dd5..cabc42756fa04 100644 --- a/google/cloud/retail/v2/internal/product_tracing_stub.cc +++ b/google/cloud/retail/v2/internal/product_tracing_stub.cc @@ -280,6 +280,30 @@ ProductServiceTracingStub::RemoveLocalInventories( child_->RemoveLocalInventories(context, options, request)); } +StatusOr +ProductServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.retail.v2.ProductService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +ProductServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.retail.v2.ProductService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + future> ProductServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/retail/v2/internal/product_tracing_stub.h b/google/cloud/retail/v2/internal/product_tracing_stub.h index 96f081c53cd5b..44612be75cb32 100644 --- a/google/cloud/retail/v2/internal/product_tracing_stub.h +++ b/google/cloud/retail/v2/internal/product_tracing_stub.h @@ -136,6 +136,14 @@ class ProductServiceTracingStub : public ProductServiceStub { google::cloud::retail::v2::RemoveLocalInventoriesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/retail/v2/internal/search_auth_decorator.cc b/google/cloud/retail/v2/internal/search_auth_decorator.cc index 139b1b30bd14c..af18af8e463a3 100644 --- a/google/cloud/retail/v2/internal/search_auth_decorator.cc +++ b/google/cloud/retail/v2/internal/search_auth_decorator.cc @@ -39,6 +39,23 @@ StatusOr SearchServiceAuth::Search( return child_->Search(context, options, request); } +StatusOr +SearchServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr SearchServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2_internal } // namespace cloud diff --git a/google/cloud/retail/v2/internal/search_auth_decorator.h b/google/cloud/retail/v2/internal/search_auth_decorator.h index 0ca88ed3a3706..b331a51cb1c2d 100644 --- a/google/cloud/retail/v2/internal/search_auth_decorator.h +++ b/google/cloud/retail/v2/internal/search_auth_decorator.h @@ -42,6 +42,14 @@ class SearchServiceAuth : public SearchServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::retail::v2::SearchRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/retail/v2/internal/search_connection_impl.cc b/google/cloud/retail/v2/internal/search_connection_impl.cc index a3dea6906184b..52f98e2294aa8 100644 --- a/google/cloud/retail/v2/internal/search_connection_impl.cc +++ b/google/cloud/retail/v2/internal/search_connection_impl.cc @@ -92,6 +92,53 @@ SearchServiceConnectionImpl::Search( }); } +StreamRange +SearchServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +SearchServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2_internal } // namespace cloud diff --git a/google/cloud/retail/v2/internal/search_connection_impl.h b/google/cloud/retail/v2/internal/search_connection_impl.h index 6d83a4cd3f98b..04953450cd4f9 100644 --- a/google/cloud/retail/v2/internal/search_connection_impl.h +++ b/google/cloud/retail/v2/internal/search_connection_impl.h @@ -51,6 +51,12 @@ class SearchServiceConnectionImpl : public retail_v2::SearchServiceConnection { StreamRange Search( google::cloud::retail::v2::SearchRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/retail/v2/internal/search_logging_decorator.cc b/google/cloud/retail/v2/internal/search_logging_decorator.cc index 5379582089057..74d49b70f2e3c 100644 --- a/google/cloud/retail/v2/internal/search_logging_decorator.cc +++ b/google/cloud/retail/v2/internal/search_logging_decorator.cc @@ -47,6 +47,29 @@ SearchServiceLogging::Search( context, options, request, __func__, tracing_options_); } +StatusOr +SearchServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr SearchServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2_internal } // namespace cloud diff --git a/google/cloud/retail/v2/internal/search_logging_decorator.h b/google/cloud/retail/v2/internal/search_logging_decorator.h index 25c60368603ec..333683818e406 100644 --- a/google/cloud/retail/v2/internal/search_logging_decorator.h +++ b/google/cloud/retail/v2/internal/search_logging_decorator.h @@ -42,6 +42,14 @@ class SearchServiceLogging : public SearchServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::retail::v2::SearchRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/retail/v2/internal/search_metadata_decorator.cc b/google/cloud/retail/v2/internal/search_metadata_decorator.cc index c85859cc5c430..4ccd2e1dc3b9a 100644 --- a/google/cloud/retail/v2/internal/search_metadata_decorator.cc +++ b/google/cloud/retail/v2/internal/search_metadata_decorator.cc @@ -54,6 +54,23 @@ SearchServiceMetadata::Search( return child_->Search(context, options, request); } +StatusOr +SearchServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr SearchServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + void SearchServiceMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/retail/v2/internal/search_metadata_decorator.h b/google/cloud/retail/v2/internal/search_metadata_decorator.h index 2acf278d964db..73446d7cd3778 100644 --- a/google/cloud/retail/v2/internal/search_metadata_decorator.h +++ b/google/cloud/retail/v2/internal/search_metadata_decorator.h @@ -42,6 +42,14 @@ class SearchServiceMetadata : public SearchServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::retail::v2::SearchRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/retail/v2/internal/search_stub.cc b/google/cloud/retail/v2/internal/search_stub.cc index 8db9006e092b3..e4735880a113b 100644 --- a/google/cloud/retail/v2/internal/search_stub.cc +++ b/google/cloud/retail/v2/internal/search_stub.cc @@ -42,6 +42,29 @@ DefaultSearchServiceStub::Search( return response; } +StatusOr +DefaultSearchServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultSearchServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2_internal } // namespace cloud diff --git a/google/cloud/retail/v2/internal/search_stub.h b/google/cloud/retail/v2/internal/search_stub.h index 79ca39483f9a6..12ace728716a7 100644 --- a/google/cloud/retail/v2/internal/search_stub.h +++ b/google/cloud/retail/v2/internal/search_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -38,22 +39,43 @@ class SearchServiceStub { virtual StatusOr Search( grpc::ClientContext& context, Options const& options, google::cloud::retail::v2::SearchRequest const& request) = 0; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; }; class DefaultSearchServiceStub : public SearchServiceStub { public: explicit DefaultSearchServiceStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr Search( grpc::ClientContext& context, Options const& options, google::cloud::retail::v2::SearchRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/retail/v2/internal/search_stub_factory.cc b/google/cloud/retail/v2/internal/search_stub_factory.cc index 6b54f10da10ba..f54272aff8b0c 100644 --- a/google/cloud/retail/v2/internal/search_stub_factory.cc +++ b/google/cloud/retail/v2/internal/search_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 CreateDefaultSearchServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::retail::v2::SearchService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_stub)); if (auth->RequiresConfigureContext()) { stub = diff --git a/google/cloud/retail/v2/internal/search_tracing_connection.cc b/google/cloud/retail/v2/internal/search_tracing_connection.cc index ed5fd2374b362..07752bc6d4166 100644 --- a/google/cloud/retail/v2/internal/search_tracing_connection.cc +++ b/google/cloud/retail/v2/internal/search_tracing_connection.cc @@ -44,6 +44,26 @@ SearchServiceTracingConnection::Search( std::move(sr)); } +StreamRange +SearchServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("retail_v2::SearchServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +SearchServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("retail_v2::SearchServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/retail/v2/internal/search_tracing_connection.h b/google/cloud/retail/v2/internal/search_tracing_connection.h index 9370a0f06f005..3aa2ed9de1e0c 100644 --- a/google/cloud/retail/v2/internal/search_tracing_connection.h +++ b/google/cloud/retail/v2/internal/search_tracing_connection.h @@ -43,6 +43,12 @@ class SearchServiceTracingConnection StreamRange Search( google::cloud::retail::v2::SearchRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/retail/v2/internal/search_tracing_stub.cc b/google/cloud/retail/v2/internal/search_tracing_stub.cc index e4de2a64888b6..95267b5680b66 100644 --- a/google/cloud/retail/v2/internal/search_tracing_stub.cc +++ b/google/cloud/retail/v2/internal/search_tracing_stub.cc @@ -44,6 +44,29 @@ SearchServiceTracingStub::Search( child_->Search(context, options, request)); } +StatusOr +SearchServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.retail.v2.SearchService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr SearchServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.retail.v2.SearchService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeSearchServiceTracingStub( diff --git a/google/cloud/retail/v2/internal/search_tracing_stub.h b/google/cloud/retail/v2/internal/search_tracing_stub.h index fada1e74f4f86..2f7b4ab380492 100644 --- a/google/cloud/retail/v2/internal/search_tracing_stub.h +++ b/google/cloud/retail/v2/internal/search_tracing_stub.h @@ -42,6 +42,14 @@ class SearchServiceTracingStub : public SearchServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::retail::v2::SearchRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/retail/v2/internal/serving_config_auth_decorator.cc b/google/cloud/retail/v2/internal/serving_config_auth_decorator.cc index 83a7908f5d3a5..0d5953f17556b 100644 --- a/google/cloud/retail/v2/internal/serving_config_auth_decorator.cc +++ b/google/cloud/retail/v2/internal/serving_config_auth_decorator.cc @@ -93,6 +93,23 @@ ServingConfigServiceAuth::RemoveControl( return child_->RemoveControl(context, options, request); } +StatusOr +ServingConfigServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr ServingConfigServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2_internal } // namespace cloud diff --git a/google/cloud/retail/v2/internal/serving_config_auth_decorator.h b/google/cloud/retail/v2/internal/serving_config_auth_decorator.h index aedb6534af378..82bcb816c2e6b 100644 --- a/google/cloud/retail/v2/internal/serving_config_auth_decorator.h +++ b/google/cloud/retail/v2/internal/serving_config_auth_decorator.h @@ -71,6 +71,14 @@ class ServingConfigServiceAuth : public ServingConfigServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::retail::v2::RemoveControlRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/retail/v2/internal/serving_config_connection_impl.cc b/google/cloud/retail/v2/internal/serving_config_connection_impl.cc index 025f7275d15f0..b17a15b172bc4 100644 --- a/google/cloud/retail/v2/internal/serving_config_connection_impl.cc +++ b/google/cloud/retail/v2/internal/serving_config_connection_impl.cc @@ -182,6 +182,53 @@ ServingConfigServiceConnectionImpl::RemoveControl( *current, request, __func__); } +StreamRange +ServingConfigServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ServingConfigServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2_internal } // namespace cloud diff --git a/google/cloud/retail/v2/internal/serving_config_connection_impl.h b/google/cloud/retail/v2/internal/serving_config_connection_impl.h index 81e1e7183370d..cd797304b4fae 100644 --- a/google/cloud/retail/v2/internal/serving_config_connection_impl.h +++ b/google/cloud/retail/v2/internal/serving_config_connection_impl.h @@ -74,6 +74,12 @@ class ServingConfigServiceConnectionImpl StatusOr RemoveControl( google::cloud::retail::v2::RemoveControlRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/retail/v2/internal/serving_config_logging_decorator.cc b/google/cloud/retail/v2/internal/serving_config_logging_decorator.cc index f7eaed8db7875..6d6623f34259b 100644 --- a/google/cloud/retail/v2/internal/serving_config_logging_decorator.cc +++ b/google/cloud/retail/v2/internal/serving_config_logging_decorator.cc @@ -123,6 +123,30 @@ ServingConfigServiceLogging::RemoveControl( context, options, request, __func__, tracing_options_); } +StatusOr +ServingConfigServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ServingConfigServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2_internal } // namespace cloud diff --git a/google/cloud/retail/v2/internal/serving_config_logging_decorator.h b/google/cloud/retail/v2/internal/serving_config_logging_decorator.h index b0c590e43191b..234dc6238b81a 100644 --- a/google/cloud/retail/v2/internal/serving_config_logging_decorator.h +++ b/google/cloud/retail/v2/internal/serving_config_logging_decorator.h @@ -71,6 +71,14 @@ class ServingConfigServiceLogging : public ServingConfigServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::retail::v2::RemoveControlRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/retail/v2/internal/serving_config_metadata_decorator.cc b/google/cloud/retail/v2/internal/serving_config_metadata_decorator.cc index e5754e37f014a..636c44dcdfc77 100644 --- a/google/cloud/retail/v2/internal/serving_config_metadata_decorator.cc +++ b/google/cloud/retail/v2/internal/serving_config_metadata_decorator.cc @@ -110,6 +110,24 @@ ServingConfigServiceMetadata::RemoveControl( return child_->RemoveControl(context, options, request); } +StatusOr +ServingConfigServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +ServingConfigServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + void ServingConfigServiceMetadata::SetMetadata( grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/retail/v2/internal/serving_config_metadata_decorator.h b/google/cloud/retail/v2/internal/serving_config_metadata_decorator.h index c41d5782d4202..58d56376c772a 100644 --- a/google/cloud/retail/v2/internal/serving_config_metadata_decorator.h +++ b/google/cloud/retail/v2/internal/serving_config_metadata_decorator.h @@ -72,6 +72,14 @@ class ServingConfigServiceMetadata : public ServingConfigServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::retail::v2::RemoveControlRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/retail/v2/internal/serving_config_stub.cc b/google/cloud/retail/v2/internal/serving_config_stub.cc index 24bddb127c8d3..23c78c8b85b69 100644 --- a/google/cloud/retail/v2/internal/serving_config_stub.cc +++ b/google/cloud/retail/v2/internal/serving_config_stub.cc @@ -113,6 +113,30 @@ DefaultServingConfigServiceStub::RemoveControl( return response; } +StatusOr +DefaultServingConfigServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultServingConfigServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2_internal } // namespace cloud diff --git a/google/cloud/retail/v2/internal/serving_config_stub.h b/google/cloud/retail/v2/internal/serving_config_stub.h index f83e240125d5e..c03e791a87e6f 100644 --- a/google/cloud/retail/v2/internal/serving_config_stub.h +++ b/google/cloud/retail/v2/internal/serving_config_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -65,6 +66,14 @@ class ServingConfigServiceStub { virtual StatusOr RemoveControl( grpc::ClientContext& context, Options const& options, google::cloud::retail::v2::RemoveControlRequest const& request) = 0; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; }; class DefaultServingConfigServiceStub : public ServingConfigServiceStub { @@ -72,8 +81,11 @@ class DefaultServingConfigServiceStub : public ServingConfigServiceStub { explicit DefaultServingConfigServiceStub( std::unique_ptr< google::cloud::retail::v2::ServingConfigService::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr CreateServingConfig( grpc::ClientContext& context, Options const& options, @@ -108,10 +120,20 @@ class DefaultServingConfigServiceStub : public ServingConfigServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::retail::v2::RemoveControlRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr< google::cloud::retail::v2::ServingConfigService::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/retail/v2/internal/serving_config_stub_factory.cc b/google/cloud/retail/v2/internal/serving_config_stub_factory.cc index ed2511e17c2ce..1886a346752c3 100644 --- a/google/cloud/retail/v2/internal/serving_config_stub_factory.cc +++ b/google/cloud/retail/v2/internal/serving_config_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 CreateDefaultServingConfigServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::retail::v2::ServingConfigService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_operations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/retail/v2/internal/serving_config_tracing_connection.cc b/google/cloud/retail/v2/internal/serving_config_tracing_connection.cc index 0761cfa3c4fe9..5190b9a8b3ccc 100644 --- a/google/cloud/retail/v2/internal/serving_config_tracing_connection.cc +++ b/google/cloud/retail/v2/internal/serving_config_tracing_connection.cc @@ -97,6 +97,26 @@ ServingConfigServiceTracingConnection::RemoveControl( return internal::EndSpan(*span, child_->RemoveControl(request)); } +StreamRange +ServingConfigServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "retail_v2::ServingConfigServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ServingConfigServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "retail_v2::ServingConfigServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/retail/v2/internal/serving_config_tracing_connection.h b/google/cloud/retail/v2/internal/serving_config_tracing_connection.h index d5f2fc47461c8..eab919dac0fcf 100644 --- a/google/cloud/retail/v2/internal/serving_config_tracing_connection.h +++ b/google/cloud/retail/v2/internal/serving_config_tracing_connection.h @@ -65,6 +65,12 @@ class ServingConfigServiceTracingConnection StatusOr RemoveControl( google::cloud::retail::v2::RemoveControlRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/retail/v2/internal/serving_config_tracing_stub.cc b/google/cloud/retail/v2/internal/serving_config_tracing_stub.cc index fbcd929d92d69..efa17b5f2f353 100644 --- a/google/cloud/retail/v2/internal/serving_config_tracing_stub.cc +++ b/google/cloud/retail/v2/internal/serving_config_tracing_stub.cc @@ -115,6 +115,30 @@ ServingConfigServiceTracingStub::RemoveControl( child_->RemoveControl(context, options, request)); } +StatusOr +ServingConfigServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.retail.v2.ServingConfigService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +ServingConfigServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.retail.v2.ServingConfigService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeServingConfigServiceTracingStub( diff --git a/google/cloud/retail/v2/internal/serving_config_tracing_stub.h b/google/cloud/retail/v2/internal/serving_config_tracing_stub.h index 08327fb1c1022..04cfc881a2397 100644 --- a/google/cloud/retail/v2/internal/serving_config_tracing_stub.h +++ b/google/cloud/retail/v2/internal/serving_config_tracing_stub.h @@ -72,6 +72,14 @@ class ServingConfigServiceTracingStub : public ServingConfigServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::retail::v2::RemoveControlRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/retail/v2/internal/user_event_auth_decorator.cc b/google/cloud/retail/v2/internal/user_event_auth_decorator.cc index c0ae1164911a8..691368b0a5c28 100644 --- a/google/cloud/retail/v2/internal/user_event_auth_decorator.cc +++ b/google/cloud/retail/v2/internal/user_event_auth_decorator.cc @@ -132,6 +132,23 @@ StatusOr UserEventServiceAuth::RejoinUserEvents( return child_->RejoinUserEvents(context, options, request); } +StatusOr +UserEventServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr UserEventServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + future> UserEventServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/retail/v2/internal/user_event_auth_decorator.h b/google/cloud/retail/v2/internal/user_event_auth_decorator.h index 6dcc3454f5536..2d970b257e006 100644 --- a/google/cloud/retail/v2/internal/user_event_auth_decorator.h +++ b/google/cloud/retail/v2/internal/user_event_auth_decorator.h @@ -84,6 +84,14 @@ class UserEventServiceAuth : public UserEventServiceStub { google::cloud::retail::v2::RejoinUserEventsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/retail/v2/internal/user_event_connection_impl.cc b/google/cloud/retail/v2/internal/user_event_connection_impl.cc index f25f7b0de4c48..c0b157b99f761 100644 --- a/google/cloud/retail/v2/internal/user_event_connection_impl.cc +++ b/google/cloud/retail/v2/internal/user_event_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 @@ -368,6 +369,53 @@ UserEventServiceConnectionImpl::RejoinUserEvents( polling_policy(*current), __func__); } +StreamRange +UserEventServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +UserEventServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2_internal } // namespace cloud diff --git a/google/cloud/retail/v2/internal/user_event_connection_impl.h b/google/cloud/retail/v2/internal/user_event_connection_impl.h index 3910644d0f63b..7e79c975891ec 100644 --- a/google/cloud/retail/v2/internal/user_event_connection_impl.h +++ b/google/cloud/retail/v2/internal/user_event_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 @@ -94,6 +95,12 @@ class UserEventServiceConnectionImpl future> RejoinUserEvents(google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/retail/v2/internal/user_event_logging_decorator.cc b/google/cloud/retail/v2/internal/user_event_logging_decorator.cc index 1b7a3aaead72e..f64c2f41bc431 100644 --- a/google/cloud/retail/v2/internal/user_event_logging_decorator.cc +++ b/google/cloud/retail/v2/internal/user_event_logging_decorator.cc @@ -153,6 +153,29 @@ UserEventServiceLogging::RejoinUserEvents( context, options, request, __func__, tracing_options_); } +StatusOr +UserEventServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr UserEventServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> UserEventServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/retail/v2/internal/user_event_logging_decorator.h b/google/cloud/retail/v2/internal/user_event_logging_decorator.h index 0a2b0858a11df..ae4f63349ee45 100644 --- a/google/cloud/retail/v2/internal/user_event_logging_decorator.h +++ b/google/cloud/retail/v2/internal/user_event_logging_decorator.h @@ -84,6 +84,14 @@ class UserEventServiceLogging : public UserEventServiceStub { google::cloud::retail::v2::RejoinUserEventsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/retail/v2/internal/user_event_metadata_decorator.cc b/google/cloud/retail/v2/internal/user_event_metadata_decorator.cc index 902ca8c5f59f3..7d4a73f6f8b93 100644 --- a/google/cloud/retail/v2/internal/user_event_metadata_decorator.cc +++ b/google/cloud/retail/v2/internal/user_event_metadata_decorator.cc @@ -124,6 +124,23 @@ UserEventServiceMetadata::RejoinUserEvents( return child_->RejoinUserEvents(context, options, request); } +StatusOr +UserEventServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr UserEventServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + future> UserEventServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/retail/v2/internal/user_event_metadata_decorator.h b/google/cloud/retail/v2/internal/user_event_metadata_decorator.h index 5c4d9dbcf0e98..5fab344d2c5f5 100644 --- a/google/cloud/retail/v2/internal/user_event_metadata_decorator.h +++ b/google/cloud/retail/v2/internal/user_event_metadata_decorator.h @@ -85,6 +85,14 @@ class UserEventServiceMetadata : public UserEventServiceStub { google::cloud::retail::v2::RejoinUserEventsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/retail/v2/internal/user_event_stub.cc b/google/cloud/retail/v2/internal/user_event_stub.cc index 4ab76be40169a..7416a3160caa1 100644 --- a/google/cloud/retail/v2/internal/user_event_stub.cc +++ b/google/cloud/retail/v2/internal/user_event_stub.cc @@ -144,6 +144,30 @@ DefaultUserEventServiceStub::RejoinUserEvents( return response; } +StatusOr +DefaultUserEventServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultUserEventServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultUserEventServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/retail/v2/internal/user_event_stub.h b/google/cloud/retail/v2/internal/user_event_stub.h index 3160fda785c7f..3475df81f58d0 100644 --- a/google/cloud/retail/v2/internal/user_event_stub.h +++ b/google/cloud/retail/v2/internal/user_event_stub.h @@ -78,6 +78,14 @@ class UserEventServiceStub { grpc::ClientContext& context, Options options, google::cloud::retail::v2::RejoinUserEventsRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -97,9 +105,13 @@ class DefaultUserEventServiceStub : public UserEventServiceStub { std::unique_ptr< google::cloud::retail::v2::UserEventService::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr WriteUserEvent( grpc::ClientContext& context, Options const& options, @@ -146,6 +158,14 @@ class DefaultUserEventServiceStub : public UserEventServiceStub { google::cloud::retail::v2::RejoinUserEventsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -161,6 +181,8 @@ class DefaultUserEventServiceStub : public UserEventServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/retail/v2/internal/user_event_stub_factory.cc b/google/cloud/retail/v2/internal/user_event_stub_factory.cc index c2fb0e635431d..baa8de7cc6f0f 100644 --- a/google/cloud/retail/v2/internal/user_event_stub_factory.cc +++ b/google/cloud/retail/v2/internal/user_event_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 CreateDefaultUserEventServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::retail::v2::UserEventService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/retail/v2/internal/user_event_tracing_connection.cc b/google/cloud/retail/v2/internal/user_event_tracing_connection.cc index bb5d6e5883fea..5b731a63d06ba 100644 --- a/google/cloud/retail/v2/internal/user_event_tracing_connection.cc +++ b/google/cloud/retail/v2/internal/user_event_tracing_connection.cc @@ -18,6 +18,7 @@ #include "google/cloud/retail/v2/internal/user_event_tracing_connection.h" #include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" #include #include @@ -139,6 +140,26 @@ UserEventServiceTracingConnection::RejoinUserEvents( child_->RejoinUserEvents(operation)); } +StreamRange +UserEventServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "retail_v2::UserEventServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +UserEventServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("retail_v2::UserEventServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/retail/v2/internal/user_event_tracing_connection.h b/google/cloud/retail/v2/internal/user_event_tracing_connection.h index d737380c975ca..6d9bac06084fc 100644 --- a/google/cloud/retail/v2/internal/user_event_tracing_connection.h +++ b/google/cloud/retail/v2/internal/user_event_tracing_connection.h @@ -83,6 +83,12 @@ class UserEventServiceTracingConnection future> RejoinUserEvents(google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/retail/v2/internal/user_event_tracing_stub.cc b/google/cloud/retail/v2/internal/user_event_tracing_stub.cc index 432ce3dc148a9..7ab12bcbd44aa 100644 --- a/google/cloud/retail/v2/internal/user_event_tracing_stub.cc +++ b/google/cloud/retail/v2/internal/user_event_tracing_stub.cc @@ -136,6 +136,30 @@ UserEventServiceTracingStub::RejoinUserEvents( child_->RejoinUserEvents(context, options, request)); } +StatusOr +UserEventServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.retail.v2.UserEventService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +UserEventServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.retail.v2.UserEventService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + future> UserEventServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/retail/v2/internal/user_event_tracing_stub.h b/google/cloud/retail/v2/internal/user_event_tracing_stub.h index 319264700a766..0abd070448eb3 100644 --- a/google/cloud/retail/v2/internal/user_event_tracing_stub.h +++ b/google/cloud/retail/v2/internal/user_event_tracing_stub.h @@ -84,6 +84,14 @@ class UserEventServiceTracingStub : public UserEventServiceStub { google::cloud::retail::v2::RejoinUserEventsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/retail/v2/mocks/mock_analytics_connection.h b/google/cloud/retail/v2/mocks/mock_analytics_connection.h index e87bf47a2863b..5f5df0439212b 100644 --- a/google/cloud/retail/v2/mocks/mock_analytics_connection.h +++ b/google/cloud/retail/v2/mocks/mock_analytics_connection.h @@ -88,6 +88,13 @@ class MockAnalyticsServiceConnection StatusOr>, ExportAnalyticsMetrics, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/retail/v2/mocks/mock_catalog_connection.h b/google/cloud/retail/v2/mocks/mock_catalog_connection.h index 884533ace1d0c..1b287193f3195 100644 --- a/google/cloud/retail/v2/mocks/mock_catalog_connection.h +++ b/google/cloud/retail/v2/mocks/mock_catalog_connection.h @@ -107,6 +107,13 @@ class MockCatalogServiceConnection (google::cloud::retail::v2::ReplaceCatalogAttributeRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/retail/v2/mocks/mock_completion_connection.h b/google/cloud/retail/v2/mocks/mock_completion_connection.h index cca3193bf88fb..2ddeddb87bf65 100644 --- a/google/cloud/retail/v2/mocks/mock_completion_connection.h +++ b/google/cloud/retail/v2/mocks/mock_completion_connection.h @@ -91,6 +91,13 @@ class MockCompletionServiceConnection future>, ImportCompletionData, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/retail/v2/mocks/mock_control_connection.h b/google/cloud/retail/v2/mocks/mock_control_connection.h index 842602e3bfd2d..24c79c34c2f3f 100644 --- a/google/cloud/retail/v2/mocks/mock_control_connection.h +++ b/google/cloud/retail/v2/mocks/mock_control_connection.h @@ -66,6 +66,13 @@ class MockControlServiceConnection MOCK_METHOD((StreamRange), ListControls, (google::cloud::retail::v2::ListControlsRequest request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/retail/v2/mocks/mock_model_connection.h b/google/cloud/retail/v2/mocks/mock_model_connection.h index 066a2bf46c48a..13e787b0a0689 100644 --- a/google/cloud/retail/v2/mocks/mock_model_connection.h +++ b/google/cloud/retail/v2/mocks/mock_model_connection.h @@ -140,6 +140,13 @@ class MockModelServiceConnection : public retail_v2::ModelServiceConnection { MOCK_METHOD(future>, TuneModel, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/retail/v2/mocks/mock_prediction_connection.h b/google/cloud/retail/v2/mocks/mock_prediction_connection.h index 5533340cc047c..e644f172704c0 100644 --- a/google/cloud/retail/v2/mocks/mock_prediction_connection.h +++ b/google/cloud/retail/v2/mocks/mock_prediction_connection.h @@ -50,6 +50,13 @@ class MockPredictionServiceConnection MOCK_METHOD(StatusOr, Predict, (google::cloud::retail::v2::PredictRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/retail/v2/mocks/mock_product_connection.h b/google/cloud/retail/v2/mocks/mock_product_connection.h index 1d385a94129a7..fc1881b96418e 100644 --- a/google/cloud/retail/v2/mocks/mock_product_connection.h +++ b/google/cloud/retail/v2/mocks/mock_product_connection.h @@ -347,6 +347,13 @@ class MockProductServiceConnection StatusOr>, RemoveLocalInventories, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/retail/v2/mocks/mock_search_connection.h b/google/cloud/retail/v2/mocks/mock_search_connection.h index 84f7ea4bfb645..dd64c860a9fef 100644 --- a/google/cloud/retail/v2/mocks/mock_search_connection.h +++ b/google/cloud/retail/v2/mocks/mock_search_connection.h @@ -49,6 +49,13 @@ class MockSearchServiceConnection : public retail_v2::SearchServiceConnection { MOCK_METHOD( (StreamRange), Search, (google::cloud::retail::v2::SearchRequest request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/retail/v2/mocks/mock_serving_config_connection.h b/google/cloud/retail/v2/mocks/mock_serving_config_connection.h index e798098ddd2e7..dd4d6ac4f7d4a 100644 --- a/google/cloud/retail/v2/mocks/mock_serving_config_connection.h +++ b/google/cloud/retail/v2/mocks/mock_serving_config_connection.h @@ -79,6 +79,13 @@ class MockServingConfigServiceConnection MOCK_METHOD(StatusOr, RemoveControl, (google::cloud::retail::v2::RemoveControlRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/retail/v2/mocks/mock_user_event_connection.h b/google/cloud/retail/v2/mocks/mock_user_event_connection.h index 4a213580334f8..864d0ec62c3ca 100644 --- a/google/cloud/retail/v2/mocks/mock_user_event_connection.h +++ b/google/cloud/retail/v2/mocks/mock_user_event_connection.h @@ -175,6 +175,13 @@ class MockUserEventServiceConnection future>, RejoinUserEvents, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/retail/v2/model_client.cc b/google/cloud/retail/v2/model_client.cc index b2fb79dd1fd47..ae7f4befb3a88 100644 --- a/google/cloud/retail/v2/model_client.cc +++ b/google/cloud/retail/v2/model_client.cc @@ -200,6 +200,35 @@ ModelServiceClient::TuneModel(google::longrunning::Operation const& operation, return connection_->TuneModel(operation); } +StreamRange ModelServiceClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange ModelServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr ModelServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr ModelServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2 } // namespace cloud diff --git a/google/cloud/retail/v2/model_client.h b/google/cloud/retail/v2/model_client.h index e5e46a56d014d..114026e5730b9 100644 --- a/google/cloud/retail/v2/model_client.h +++ b/google/cloud/retail/v2/model_client.h @@ -694,6 +694,158 @@ class ModelServiceClient { future> TuneModel( google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/retail/v2/model_connection.cc b/google/cloud/retail/v2/model_connection.cc index 3afae566fd165..666d10dba9579 100644 --- a/google/cloud/retail/v2/model_connection.cc +++ b/google/cloud/retail/v2/model_connection.cc @@ -113,6 +113,19 @@ ModelServiceConnection::TuneModel(google::longrunning::Operation const&) { Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +ModelServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr ModelServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeModelServiceConnection( Options options) { internal::CheckExpectedOptions> TuneModel(google::longrunning::Operation const& operation); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/retail/v2/model_connection_idempotency_policy.cc b/google/cloud/retail/v2/model_connection_idempotency_policy.cc index b2c0288ed40a1..fc64116e096ac 100644 --- a/google/cloud/retail/v2/model_connection_idempotency_policy.cc +++ b/google/cloud/retail/v2/model_connection_idempotency_policy.cc @@ -74,6 +74,16 @@ Idempotency ModelServiceConnectionIdempotencyPolicy::TuneModel( return Idempotency::kNonIdempotent; } +Idempotency ModelServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ModelServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultModelServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/retail/v2/model_connection_idempotency_policy.h b/google/cloud/retail/v2/model_connection_idempotency_policy.h index 2043456191407..0862f56c4906e 100644 --- a/google/cloud/retail/v2/model_connection_idempotency_policy.h +++ b/google/cloud/retail/v2/model_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 ModelServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency TuneModel( google::cloud::retail::v2::TuneModelRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/retail/v2/prediction_client.cc b/google/cloud/retail/v2/prediction_client.cc index d5352c6b02a76..bd71cbdbfaf62 100644 --- a/google/cloud/retail/v2/prediction_client.cc +++ b/google/cloud/retail/v2/prediction_client.cc @@ -39,6 +39,38 @@ PredictionServiceClient::Predict( return connection_->Predict(request); } +StreamRange +PredictionServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +PredictionServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr PredictionServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr PredictionServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2 } // namespace cloud diff --git a/google/cloud/retail/v2/prediction_client.h b/google/cloud/retail/v2/prediction_client.h index ddc55e8373275..d110bba312085 100644 --- a/google/cloud/retail/v2/prediction_client.h +++ b/google/cloud/retail/v2/prediction_client.h @@ -118,6 +118,158 @@ class PredictionServiceClient { google::cloud::retail::v2::PredictRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/retail/v2/prediction_connection.cc b/google/cloud/retail/v2/prediction_connection.cc index 0f71dcf6fbecb..5b6428c8ba2a8 100644 --- a/google/cloud/retail/v2/prediction_connection.cc +++ b/google/cloud/retail/v2/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 @@ -43,6 +44,20 @@ PredictionServiceConnection::Predict( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +PredictionServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +PredictionServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakePredictionServiceConnection( Options options) { internal::CheckExpectedOptions #include @@ -184,6 +185,12 @@ class PredictionServiceConnection { virtual StatusOr Predict( google::cloud::retail::v2::PredictRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/retail/v2/prediction_connection_idempotency_policy.cc b/google/cloud/retail/v2/prediction_connection_idempotency_policy.cc index ed51899385d8d..18287eaa0525d 100644 --- a/google/cloud/retail/v2/prediction_connection_idempotency_policy.cc +++ b/google/cloud/retail/v2/prediction_connection_idempotency_policy.cc @@ -39,6 +39,16 @@ Idempotency PredictionServiceConnectionIdempotencyPolicy::Predict( return Idempotency::kNonIdempotent; } +Idempotency PredictionServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency PredictionServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultPredictionServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/retail/v2/prediction_connection_idempotency_policy.h b/google/cloud/retail/v2/prediction_connection_idempotency_policy.h index 60aa9d0d1c391..56f095a30505d 100644 --- a/google/cloud/retail/v2/prediction_connection_idempotency_policy.h +++ b/google/cloud/retail/v2/prediction_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -39,6 +40,12 @@ class PredictionServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency Predict( google::cloud::retail::v2::PredictRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/retail/v2/product_client.cc b/google/cloud/retail/v2/product_client.cc index e8d1fa27b1773..e373227dbf482 100644 --- a/google/cloud/retail/v2/product_client.cc +++ b/google/cloud/retail/v2/product_client.cc @@ -375,6 +375,37 @@ ProductServiceClient::RemoveLocalInventories( return connection_->RemoveLocalInventories(operation); } +StreamRange +ProductServiceClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +ProductServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr ProductServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr ProductServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2 } // namespace cloud diff --git a/google/cloud/retail/v2/product_client.h b/google/cloud/retail/v2/product_client.h index 84288fe834368..de9ef041e9d1e 100644 --- a/google/cloud/retail/v2/product_client.h +++ b/google/cloud/retail/v2/product_client.h @@ -1643,6 +1643,158 @@ class ProductServiceClient { RemoveLocalInventories(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/retail/v2/product_connection.cc b/google/cloud/retail/v2/product_connection.cc index c48acf17e4f14..75ddfedb80042 100644 --- a/google/cloud/retail/v2/product_connection.cc +++ b/google/cloud/retail/v2/product_connection.cc @@ -229,6 +229,19 @@ ProductServiceConnection::RemoveLocalInventories( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +ProductServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr ProductServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeProductServiceConnection( Options options) { internal::CheckExpectedOptions> RemoveLocalInventories(google::longrunning::Operation const& operation); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/retail/v2/product_connection_idempotency_policy.cc b/google/cloud/retail/v2/product_connection_idempotency_policy.cc index 3bbce389d40a2..c9d45e7fda63d 100644 --- a/google/cloud/retail/v2/product_connection_idempotency_policy.cc +++ b/google/cloud/retail/v2/product_connection_idempotency_policy.cc @@ -94,6 +94,16 @@ Idempotency ProductServiceConnectionIdempotencyPolicy::RemoveLocalInventories( return Idempotency::kNonIdempotent; } +Idempotency ProductServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ProductServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultProductServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/retail/v2/product_connection_idempotency_policy.h b/google/cloud/retail/v2/product_connection_idempotency_policy.h index 137219c32a0e7..117bb0c62cb94 100644 --- a/google/cloud/retail/v2/product_connection_idempotency_policy.h +++ b/google/cloud/retail/v2/product_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -72,6 +73,12 @@ class ProductServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency RemoveLocalInventories( google::cloud::retail::v2::RemoveLocalInventoriesRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/retail/v2/search_client.cc b/google/cloud/retail/v2/search_client.cc index 0fc490683b61d..cdb1a4f9d9ba6 100644 --- a/google/cloud/retail/v2/search_client.cc +++ b/google/cloud/retail/v2/search_client.cc @@ -39,6 +39,35 @@ SearchServiceClient::Search(google::cloud::retail::v2::SearchRequest request, return connection_->Search(std::move(request)); } +StreamRange SearchServiceClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange SearchServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr SearchServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr SearchServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2 } // namespace cloud diff --git a/google/cloud/retail/v2/search_client.h b/google/cloud/retail/v2/search_client.h index 9468cc637a2de..1efb2324d3b94 100644 --- a/google/cloud/retail/v2/search_client.h +++ b/google/cloud/retail/v2/search_client.h @@ -131,6 +131,158 @@ class SearchServiceClient { StreamRange Search( google::cloud::retail::v2::SearchRequest request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/retail/v2/search_connection.cc b/google/cloud/retail/v2/search_connection.cc index 6e2f7ab2f86ca..a61959f3f253c 100644 --- a/google/cloud/retail/v2/search_connection.cc +++ b/google/cloud/retail/v2/search_connection.cc @@ -46,6 +46,19 @@ SearchServiceConnection::Search( StreamRange>(); } +StreamRange +SearchServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr SearchServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSearchServiceConnection( Options options) { internal::CheckExpectedOptions Search(google::cloud::retail::v2::SearchRequest request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/retail/v2/search_connection_idempotency_policy.cc b/google/cloud/retail/v2/search_connection_idempotency_policy.cc index 9dc97fc5262b5..fd5c44f5000fc 100644 --- a/google/cloud/retail/v2/search_connection_idempotency_policy.cc +++ b/google/cloud/retail/v2/search_connection_idempotency_policy.cc @@ -39,6 +39,16 @@ Idempotency SearchServiceConnectionIdempotencyPolicy::Search( return Idempotency::kNonIdempotent; } +Idempotency SearchServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SearchServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultSearchServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/retail/v2/search_connection_idempotency_policy.h b/google/cloud/retail/v2/search_connection_idempotency_policy.h index d60a4a4670ba6..529101d62f6de 100644 --- a/google/cloud/retail/v2/search_connection_idempotency_policy.h +++ b/google/cloud/retail/v2/search_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -39,6 +40,12 @@ class SearchServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency Search( google::cloud::retail::v2::SearchRequest request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/retail/v2/serving_config_client.cc b/google/cloud/retail/v2/serving_config_client.cc index c42cef4feb203..2d240b0f83707 100644 --- a/google/cloud/retail/v2/serving_config_client.cc +++ b/google/cloud/retail/v2/serving_config_client.cc @@ -154,6 +154,40 @@ ServingConfigServiceClient::RemoveControl( return connection_->RemoveControl(request); } +StreamRange +ServingConfigServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +ServingConfigServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +ServingConfigServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +ServingConfigServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2 } // namespace cloud diff --git a/google/cloud/retail/v2/serving_config_client.h b/google/cloud/retail/v2/serving_config_client.h index a5315e07306d8..be1685787756f 100644 --- a/google/cloud/retail/v2/serving_config_client.h +++ b/google/cloud/retail/v2/serving_config_client.h @@ -547,6 +547,158 @@ class ServingConfigServiceClient { google::cloud::retail::v2::RemoveControlRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/retail/v2/serving_config_connection.cc b/google/cloud/retail/v2/serving_config_connection.cc index 21cb740a05ea3..815aecf956fa6 100644 --- a/google/cloud/retail/v2/serving_config_connection.cc +++ b/google/cloud/retail/v2/serving_config_connection.cc @@ -81,6 +81,20 @@ ServingConfigServiceConnection::RemoveControl( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +ServingConfigServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +ServingConfigServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeServingConfigServiceConnection(Options options) { internal::CheckExpectedOptions RemoveControl( google::cloud::retail::v2::RemoveControlRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/retail/v2/serving_config_connection_idempotency_policy.cc b/google/cloud/retail/v2/serving_config_connection_idempotency_policy.cc index c5f2743b066fd..68f9b92b9d31d 100644 --- a/google/cloud/retail/v2/serving_config_connection_idempotency_policy.cc +++ b/google/cloud/retail/v2/serving_config_connection_idempotency_policy.cc @@ -73,6 +73,16 @@ Idempotency ServingConfigServiceConnectionIdempotencyPolicy::RemoveControl( return Idempotency::kNonIdempotent; } +Idempotency ServingConfigServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ServingConfigServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultServingConfigServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/retail/v2/serving_config_connection_idempotency_policy.h b/google/cloud/retail/v2/serving_config_connection_idempotency_policy.h index 0c525f9b08be1..1b74b29c4f111 100644 --- a/google/cloud/retail/v2/serving_config_connection_idempotency_policy.h +++ b/google/cloud/retail/v2/serving_config_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,12 @@ class ServingConfigServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency RemoveControl( google::cloud::retail::v2::RemoveControlRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/retail/v2/user_event_client.cc b/google/cloud/retail/v2/user_event_client.cc index 1b495d531b3fd..06a7f10c167ef 100644 --- a/google/cloud/retail/v2/user_event_client.cc +++ b/google/cloud/retail/v2/user_event_client.cc @@ -119,6 +119,38 @@ UserEventServiceClient::RejoinUserEvents( return connection_->RejoinUserEvents(operation); } +StreamRange +UserEventServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +UserEventServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr UserEventServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr UserEventServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2 } // namespace cloud diff --git a/google/cloud/retail/v2/user_event_client.h b/google/cloud/retail/v2/user_event_client.h index 054d72d1ed061..2e38eac80e55c 100644 --- a/google/cloud/retail/v2/user_event_client.h +++ b/google/cloud/retail/v2/user_event_client.h @@ -375,6 +375,158 @@ class UserEventServiceClient { RejoinUserEvents(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/retail/v2/user_event_connection.cc b/google/cloud/retail/v2/user_event_connection.cc index 5b2eb27bb7699..c917cc7a22f60 100644 --- a/google/cloud/retail/v2/user_event_connection.cc +++ b/google/cloud/retail/v2/user_event_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 @@ -117,6 +118,20 @@ UserEventServiceConnection::RejoinUserEvents( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +UserEventServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +UserEventServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeUserEventServiceConnection( Options options) { internal::CheckExpectedOptions #include @@ -224,6 +225,12 @@ class UserEventServiceConnection { virtual future> RejoinUserEvents(google::longrunning::Operation const& operation); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/retail/v2/user_event_connection_idempotency_policy.cc b/google/cloud/retail/v2/user_event_connection_idempotency_policy.cc index c91625292aa2e..cd3643641c36b 100644 --- a/google/cloud/retail/v2/user_event_connection_idempotency_policy.cc +++ b/google/cloud/retail/v2/user_event_connection_idempotency_policy.cc @@ -59,6 +59,16 @@ Idempotency UserEventServiceConnectionIdempotencyPolicy::RejoinUserEvents( return Idempotency::kNonIdempotent; } +Idempotency UserEventServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency UserEventServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultUserEventServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/retail/v2/user_event_connection_idempotency_policy.h b/google/cloud/retail/v2/user_event_connection_idempotency_policy.h index 0cb2446c11bbb..6359d5d652fef 100644 --- a/google/cloud/retail/v2/user_event_connection_idempotency_policy.h +++ b/google/cloud/retail/v2/user_event_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 UserEventServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency RejoinUserEvents( google::cloud::retail::v2::RejoinUserEventsRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr 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_client.cc b/google/cloud/run/v2/executions_client.cc index ee84ba05a0a67..c8bbf67d293f0 100644 --- a/google/cloud/run/v2/executions_client.cc +++ b/google/cloud/run/v2/executions_client.cc @@ -136,6 +136,55 @@ ExecutionsClient::CancelExecution( return connection_->CancelExecution(operation); } +StreamRange ExecutionsClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange ExecutionsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr ExecutionsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr ExecutionsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status ExecutionsClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status ExecutionsClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +StatusOr ExecutionsClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace run_v2 } // namespace cloud diff --git a/google/cloud/run/v2/executions_client.h b/google/cloud/run/v2/executions_client.h index 4cc69c8dc1419..eedaafd015801 100644 --- a/google/cloud/run/v2/executions_client.h +++ b/google/cloud/run/v2/executions_client.h @@ -451,6 +451,252 @@ class ExecutionsClient { future> CancelExecution( google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/run/v2/executions_connection.cc b/google/cloud/run/v2/executions_connection.cc index e27ca97497553..8f342268876a1 100644 --- a/google/cloud/run/v2/executions_connection.cc +++ b/google/cloud/run/v2/executions_connection.cc @@ -93,6 +93,29 @@ ExecutionsConnection::CancelExecution(google::longrunning::Operation const&) { Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +ExecutionsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr ExecutionsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ExecutionsConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr ExecutionsConnection::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeExecutionsConnection( Options options) { internal::CheckExpectedOptions> CancelExecution( google::longrunning::Operation const& operation); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest const& request); }; /** diff --git a/google/cloud/run/v2/executions_connection_idempotency_policy.cc b/google/cloud/run/v2/executions_connection_idempotency_policy.cc index 946fe52354816..680a925ed88ce 100644 --- a/google/cloud/run/v2/executions_connection_idempotency_policy.cc +++ b/google/cloud/run/v2/executions_connection_idempotency_policy.cc @@ -54,6 +54,26 @@ Idempotency ExecutionsConnectionIdempotencyPolicy::CancelExecution( return Idempotency::kNonIdempotent; } +Idempotency ExecutionsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ExecutionsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ExecutionsConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency ExecutionsConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultExecutionsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/run/v2/executions_connection_idempotency_policy.h b/google/cloud/run/v2/executions_connection_idempotency_policy.h index b457349b3e3f4..9b071a5877b7a 100644 --- a/google/cloud/run/v2/executions_connection_idempotency_policy.h +++ b/google/cloud/run/v2/executions_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -47,6 +48,18 @@ class ExecutionsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency CancelExecution( google::cloud::run::v2::CancelExecutionRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/run/v2/internal/executions_auth_decorator.cc b/google/cloud/run/v2/internal/executions_auth_decorator.cc index d6ec7fdd20ffa..1f0f35ef45d55 100644 --- a/google/cloud/run/v2/internal/executions_auth_decorator.cc +++ b/google/cloud/run/v2/internal/executions_auth_decorator.cc @@ -104,6 +104,39 @@ StatusOr ExecutionsAuth::CancelExecution( return child_->CancelExecution(context, options, request); } +StatusOr +ExecutionsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr ExecutionsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status ExecutionsAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +StatusOr ExecutionsAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(context, options, request); +} + future> ExecutionsAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/run/v2/internal/executions_auth_decorator.h b/google/cloud/run/v2/internal/executions_auth_decorator.h index 769433b7fc981..58fec74f585c8 100644 --- a/google/cloud/run/v2/internal/executions_auth_decorator.h +++ b/google/cloud/run/v2/internal/executions_auth_decorator.h @@ -67,6 +67,22 @@ class ExecutionsAuth : public ExecutionsStub { grpc::ClientContext& context, Options options, google::cloud::run::v2::CancelExecutionRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/run/v2/internal/executions_connection_impl.cc b/google/cloud/run/v2/internal/executions_connection_impl.cc index 6bbfbf64ca1e8..9ae4eac2f3f08 100644 --- a/google/cloud/run/v2/internal/executions_connection_impl.cc +++ b/google/cloud/run/v2/internal/executions_connection_impl.cc @@ -286,6 +286,79 @@ ExecutionsConnectionImpl::CancelExecution( polling_policy(*current), __func__); } +StreamRange +ExecutionsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr ExecutionsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ExecutionsConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +ExecutionsConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace run_v2_internal } // namespace cloud diff --git a/google/cloud/run/v2/internal/executions_connection_impl.h b/google/cloud/run/v2/internal/executions_connection_impl.h index 1272f0de2299d..4b08ed9db6b49 100644 --- a/google/cloud/run/v2/internal/executions_connection_impl.h +++ b/google/cloud/run/v2/internal/executions_connection_impl.h @@ -76,6 +76,18 @@ class ExecutionsConnectionImpl : public run_v2::ExecutionsConnection { future> CancelExecution( google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/run/v2/internal/executions_logging_decorator.cc b/google/cloud/run/v2/internal/executions_logging_decorator.cc index 0b0cab2f083a8..1a7fbaf2ce65c 100644 --- a/google/cloud/run/v2/internal/executions_logging_decorator.cc +++ b/google/cloud/run/v2/internal/executions_logging_decorator.cc @@ -116,6 +116,51 @@ StatusOr ExecutionsLogging::CancelExecution( context, options, request, __func__, tracing_options_); } +StatusOr +ExecutionsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ExecutionsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ExecutionsLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ExecutionsLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> ExecutionsLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/run/v2/internal/executions_logging_decorator.h b/google/cloud/run/v2/internal/executions_logging_decorator.h index 425f0d2a6d4ea..758f5bb426c02 100644 --- a/google/cloud/run/v2/internal/executions_logging_decorator.h +++ b/google/cloud/run/v2/internal/executions_logging_decorator.h @@ -67,6 +67,22 @@ class ExecutionsLogging : public ExecutionsStub { grpc::ClientContext& context, Options options, google::cloud::run::v2::CancelExecutionRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/run/v2/internal/executions_metadata_decorator.cc b/google/cloud/run/v2/internal/executions_metadata_decorator.cc index 8da740c88643d..fbfd08061cebf 100644 --- a/google/cloud/run/v2/internal/executions_metadata_decorator.cc +++ b/google/cloud/run/v2/internal/executions_metadata_decorator.cc @@ -101,6 +101,38 @@ StatusOr ExecutionsMetadata::CancelExecution( return child_->CancelExecution(context, options, request); } +StatusOr +ExecutionsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr ExecutionsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status ExecutionsMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +StatusOr ExecutionsMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(context, options, request); +} + future> ExecutionsMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/run/v2/internal/executions_metadata_decorator.h b/google/cloud/run/v2/internal/executions_metadata_decorator.h index 5c07b865cc4ec..252c4c73596d5 100644 --- a/google/cloud/run/v2/internal/executions_metadata_decorator.h +++ b/google/cloud/run/v2/internal/executions_metadata_decorator.h @@ -67,6 +67,22 @@ class ExecutionsMetadata : public ExecutionsStub { grpc::ClientContext& context, Options options, google::cloud::run::v2::CancelExecutionRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/run/v2/internal/executions_stub.cc b/google/cloud/run/v2/internal/executions_stub.cc index 8f10b34b5180c..e99a662b66dda 100644 --- a/google/cloud/run/v2/internal/executions_stub.cc +++ b/google/cloud/run/v2/internal/executions_stub.cc @@ -112,6 +112,51 @@ StatusOr DefaultExecutionsStub::CancelExecution( return response; } +StatusOr +DefaultExecutionsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultExecutionsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultExecutionsStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr DefaultExecutionsStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultExecutionsStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/run/v2/internal/executions_stub.h b/google/cloud/run/v2/internal/executions_stub.h index ddcdc4719cb15..d70c5a43d19df 100644 --- a/google/cloud/run/v2/internal/executions_stub.h +++ b/google/cloud/run/v2/internal/executions_stub.h @@ -68,6 +68,22 @@ class ExecutionsStub { grpc::ClientContext& context, Options options, google::cloud::run::v2::CancelExecutionRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -86,9 +102,13 @@ class DefaultExecutionsStub : public ExecutionsStub { DefaultExecutionsStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr GetExecution( grpc::ClientContext& context, Options const& options, @@ -118,6 +138,22 @@ class DefaultExecutionsStub : public ExecutionsStub { grpc::ClientContext& context, Options options, google::cloud::run::v2::CancelExecutionRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -132,6 +168,8 @@ class DefaultExecutionsStub : public ExecutionsStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/run/v2/internal/executions_stub_factory.cc b/google/cloud/run/v2/internal/executions_stub_factory.cc index 316db3cc39769..33db1205139cb 100644 --- a/google/cloud/run/v2/internal/executions_stub_factory.cc +++ b/google/cloud/run/v2/internal/executions_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -43,9 +44,11 @@ std::shared_ptr CreateDefaultExecutionsStub( auto channel = auth->CreateChannel(options.get(), internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::run::v2::Executions::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/run/v2/internal/executions_tracing_connection.cc b/google/cloud/run/v2/internal/executions_tracing_connection.cc index 4e53b0cc27489..9203d5caa4af8 100644 --- a/google/cloud/run/v2/internal/executions_tracing_connection.cc +++ b/google/cloud/run/v2/internal/executions_tracing_connection.cc @@ -108,6 +108,41 @@ ExecutionsTracingConnection::CancelExecution( return internal::EndSpan(std::move(span), child_->CancelExecution(operation)); } +StreamRange +ExecutionsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("run_v2::ExecutionsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ExecutionsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan("run_v2::ExecutionsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status ExecutionsTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = + internal::MakeSpan("run_v2::ExecutionsConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +StatusOr +ExecutionsTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan("run_v2::ExecutionsConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeExecutionsTracingConnection( diff --git a/google/cloud/run/v2/internal/executions_tracing_connection.h b/google/cloud/run/v2/internal/executions_tracing_connection.h index 8dece5e6467ff..b308484335e48 100644 --- a/google/cloud/run/v2/internal/executions_tracing_connection.h +++ b/google/cloud/run/v2/internal/executions_tracing_connection.h @@ -65,6 +65,18 @@ class ExecutionsTracingConnection : public run_v2::ExecutionsConnection { future> CancelExecution( google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/run/v2/internal/executions_tracing_stub.cc b/google/cloud/run/v2/internal/executions_tracing_stub.cc index b40b7bbd669b5..06d5ad761dfe3 100644 --- a/google/cloud/run/v2/internal/executions_tracing_stub.cc +++ b/google/cloud/run/v2/internal/executions_tracing_stub.cc @@ -107,6 +107,51 @@ StatusOr ExecutionsTracingStub::CancelExecution( child_->CancelExecution(context, options, request)); } +StatusOr +ExecutionsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.run.v2.Executions", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr ExecutionsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.run.v2.Executions", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status ExecutionsTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.run.v2.Executions", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +StatusOr ExecutionsTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.run.v2.Executions", "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(context, options, request)); +} + future> ExecutionsTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/run/v2/internal/executions_tracing_stub.h b/google/cloud/run/v2/internal/executions_tracing_stub.h index 42880ef6905bd..d4ded9b10f192 100644 --- a/google/cloud/run/v2/internal/executions_tracing_stub.h +++ b/google/cloud/run/v2/internal/executions_tracing_stub.h @@ -66,6 +66,22 @@ class ExecutionsTracingStub : public ExecutionsStub { grpc::ClientContext& context, Options options, google::cloud::run::v2::CancelExecutionRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/run/v2/internal/jobs_auth_decorator.cc b/google/cloud/run/v2/internal/jobs_auth_decorator.cc index 2e9ae85d95f0b..e43a92f37f728 100644 --- a/google/cloud/run/v2/internal/jobs_auth_decorator.cc +++ b/google/cloud/run/v2/internal/jobs_auth_decorator.cc @@ -180,6 +180,38 @@ JobsAuth::TestIamPermissions( return child_->TestIamPermissions(context, options, request); } +StatusOr JobsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr JobsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status JobsAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +StatusOr JobsAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(context, options, request); +} + future> JobsAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/run/v2/internal/jobs_auth_decorator.h b/google/cloud/run/v2/internal/jobs_auth_decorator.h index 3dd1675b4e12d..a84c01a944207 100644 --- a/google/cloud/run/v2/internal/jobs_auth_decorator.h +++ b/google/cloud/run/v2/internal/jobs_auth_decorator.h @@ -99,6 +99,22 @@ class JobsAuth : public JobsStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/run/v2/internal/jobs_connection_impl.cc b/google/cloud/run/v2/internal/jobs_connection_impl.cc index c9f6b6b0bcb09..d0c1ce4148e66 100644 --- a/google/cloud/run/v2/internal/jobs_connection_impl.cc +++ b/google/cloud/run/v2/internal/jobs_connection_impl.cc @@ -475,6 +475,76 @@ JobsConnectionImpl::TestIamPermissions( *current, request, __func__); } +StreamRange JobsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr JobsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status JobsConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr JobsConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace run_v2_internal } // namespace cloud diff --git a/google/cloud/run/v2/internal/jobs_connection_impl.h b/google/cloud/run/v2/internal/jobs_connection_impl.h index d17e63a9c7a8a..75a23aab2334b 100644 --- a/google/cloud/run/v2/internal/jobs_connection_impl.h +++ b/google/cloud/run/v2/internal/jobs_connection_impl.h @@ -105,6 +105,18 @@ class JobsConnectionImpl : public run_v2::JobsConnection { StatusOr TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/run/v2/internal/jobs_logging_decorator.cc b/google/cloud/run/v2/internal/jobs_logging_decorator.cc index 1d61b629354a3..bfa934deb6731 100644 --- a/google/cloud/run/v2/internal/jobs_logging_decorator.cc +++ b/google/cloud/run/v2/internal/jobs_logging_decorator.cc @@ -203,6 +203,51 @@ JobsLogging::TestIamPermissions( context, options, request, __func__, tracing_options_); } +StatusOr +JobsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr JobsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status JobsLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr JobsLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> JobsLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/run/v2/internal/jobs_logging_decorator.h b/google/cloud/run/v2/internal/jobs_logging_decorator.h index 4962bc801e9d7..553a70d1d873c 100644 --- a/google/cloud/run/v2/internal/jobs_logging_decorator.h +++ b/google/cloud/run/v2/internal/jobs_logging_decorator.h @@ -98,6 +98,22 @@ class JobsLogging : public JobsStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/run/v2/internal/jobs_metadata_decorator.cc b/google/cloud/run/v2/internal/jobs_metadata_decorator.cc index c4ec724b444b8..380be7f664ddd 100644 --- a/google/cloud/run/v2/internal/jobs_metadata_decorator.cc +++ b/google/cloud/run/v2/internal/jobs_metadata_decorator.cc @@ -356,6 +356,38 @@ JobsMetadata::TestIamPermissions( return child_->TestIamPermissions(context, options, request); } +StatusOr +JobsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr JobsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status JobsMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +StatusOr JobsMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(context, options, request); +} + future> JobsMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/run/v2/internal/jobs_metadata_decorator.h b/google/cloud/run/v2/internal/jobs_metadata_decorator.h index 141667d8007f0..c2bc33ce54ce3 100644 --- a/google/cloud/run/v2/internal/jobs_metadata_decorator.h +++ b/google/cloud/run/v2/internal/jobs_metadata_decorator.h @@ -99,6 +99,22 @@ class JobsMetadata : public JobsStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/run/v2/internal/jobs_stub.cc b/google/cloud/run/v2/internal/jobs_stub.cc index 22d637f2c4d6e..cab9c3a8ed1fe 100644 --- a/google/cloud/run/v2/internal/jobs_stub.cc +++ b/google/cloud/run/v2/internal/jobs_stub.cc @@ -198,6 +198,51 @@ DefaultJobsStub::TestIamPermissions( return response; } +StatusOr +DefaultJobsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultJobsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultJobsStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr DefaultJobsStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultJobsStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/run/v2/internal/jobs_stub.h b/google/cloud/run/v2/internal/jobs_stub.h index dbaa402a0cff5..5644b4f75fe4c 100644 --- a/google/cloud/run/v2/internal/jobs_stub.h +++ b/google/cloud/run/v2/internal/jobs_stub.h @@ -100,6 +100,22 @@ class JobsStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -117,9 +133,13 @@ class DefaultJobsStub : public JobsStub { public: DefaultJobsStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateJob( google::cloud::CompletionQueue& cq, @@ -181,6 +201,22 @@ class DefaultJobsStub : public JobsStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -195,6 +231,8 @@ class DefaultJobsStub : public JobsStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/run/v2/internal/jobs_stub_factory.cc b/google/cloud/run/v2/internal/jobs_stub_factory.cc index 94efb0dc1b148..d1e964185b054 100644 --- a/google/cloud/run/v2/internal/jobs_stub_factory.cc +++ b/google/cloud/run/v2/internal/jobs_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -43,8 +44,10 @@ std::shared_ptr CreateDefaultJobsStub( auto channel = auth->CreateChannel(options.get(), internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::run::v2::Jobs::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/run/v2/internal/jobs_tracing_connection.cc b/google/cloud/run/v2/internal/jobs_tracing_connection.cc index 606d92fc23477..addfcfcfe6685 100644 --- a/google/cloud/run/v2/internal/jobs_tracing_connection.cc +++ b/google/cloud/run/v2/internal/jobs_tracing_connection.cc @@ -156,6 +156,37 @@ JobsTracingConnection::TestIamPermissions( return internal::EndSpan(*span, child_->TestIamPermissions(request)); } +StreamRange +JobsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan("run_v2::JobsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr JobsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan("run_v2::JobsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status JobsTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan("run_v2::JobsConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +StatusOr JobsTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan("run_v2::JobsConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeJobsTracingConnection( diff --git a/google/cloud/run/v2/internal/jobs_tracing_connection.h b/google/cloud/run/v2/internal/jobs_tracing_connection.h index ba11e392c6067..328cc1e2152d1 100644 --- a/google/cloud/run/v2/internal/jobs_tracing_connection.h +++ b/google/cloud/run/v2/internal/jobs_tracing_connection.h @@ -93,6 +93,18 @@ class JobsTracingConnection : public run_v2::JobsConnection { StatusOr TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/run/v2/internal/jobs_tracing_stub.cc b/google/cloud/run/v2/internal/jobs_tracing_stub.cc index 318a8f0cf3b3e..bfd5aa7af16ba 100644 --- a/google/cloud/run/v2/internal/jobs_tracing_stub.cc +++ b/google/cloud/run/v2/internal/jobs_tracing_stub.cc @@ -176,6 +176,51 @@ JobsTracingStub::TestIamPermissions( context, *span, child_->TestIamPermissions(context, options, request)); } +StatusOr +JobsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.run.v2.Jobs", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr JobsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.run.v2.Jobs", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status JobsTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.run.v2.Jobs", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +StatusOr JobsTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.run.v2.Jobs", "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(context, options, request)); +} + future> JobsTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/run/v2/internal/jobs_tracing_stub.h b/google/cloud/run/v2/internal/jobs_tracing_stub.h index f98028ee1ea73..3bff4cccac581 100644 --- a/google/cloud/run/v2/internal/jobs_tracing_stub.h +++ b/google/cloud/run/v2/internal/jobs_tracing_stub.h @@ -98,6 +98,22 @@ class JobsTracingStub : public JobsStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/run/v2/internal/revisions_auth_decorator.cc b/google/cloud/run/v2/internal/revisions_auth_decorator.cc index 0154ca3e8a76f..c84a135a697d7 100644 --- a/google/cloud/run/v2/internal/revisions_auth_decorator.cc +++ b/google/cloud/run/v2/internal/revisions_auth_decorator.cc @@ -76,6 +76,39 @@ StatusOr RevisionsAuth::DeleteRevision( return child_->DeleteRevision(context, options, request); } +StatusOr +RevisionsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr RevisionsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status RevisionsAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +StatusOr RevisionsAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(context, options, request); +} + future> RevisionsAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/run/v2/internal/revisions_auth_decorator.h b/google/cloud/run/v2/internal/revisions_auth_decorator.h index 715b39107e469..97e08c530e1b5 100644 --- a/google/cloud/run/v2/internal/revisions_auth_decorator.h +++ b/google/cloud/run/v2/internal/revisions_auth_decorator.h @@ -57,6 +57,22 @@ class RevisionsAuth : public RevisionsStub { grpc::ClientContext& context, Options options, google::cloud::run::v2::DeleteRevisionRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/run/v2/internal/revisions_connection_impl.cc b/google/cloud/run/v2/internal/revisions_connection_impl.cc index 0558286a2e223..3e2e390547ff7 100644 --- a/google/cloud/run/v2/internal/revisions_connection_impl.cc +++ b/google/cloud/run/v2/internal/revisions_connection_impl.cc @@ -197,6 +197,78 @@ RevisionsConnectionImpl::DeleteRevision( polling_policy(*current), __func__); } +StreamRange +RevisionsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr RevisionsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status RevisionsConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr RevisionsConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace run_v2_internal } // namespace cloud diff --git a/google/cloud/run/v2/internal/revisions_connection_impl.h b/google/cloud/run/v2/internal/revisions_connection_impl.h index 51dd3106353c1..b3fee19a82ca3 100644 --- a/google/cloud/run/v2/internal/revisions_connection_impl.h +++ b/google/cloud/run/v2/internal/revisions_connection_impl.h @@ -66,6 +66,18 @@ class RevisionsConnectionImpl : public run_v2::RevisionsConnection { future> DeleteRevision( google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/run/v2/internal/revisions_logging_decorator.cc b/google/cloud/run/v2/internal/revisions_logging_decorator.cc index f8e8ee67cac25..c8573540b970e 100644 --- a/google/cloud/run/v2/internal/revisions_logging_decorator.cc +++ b/google/cloud/run/v2/internal/revisions_logging_decorator.cc @@ -87,6 +87,51 @@ StatusOr RevisionsLogging::DeleteRevision( context, options, request, __func__, tracing_options_); } +StatusOr +RevisionsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr RevisionsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status RevisionsLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr RevisionsLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> RevisionsLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/run/v2/internal/revisions_logging_decorator.h b/google/cloud/run/v2/internal/revisions_logging_decorator.h index 811d9a493b572..ba4e2bd4a3ecd 100644 --- a/google/cloud/run/v2/internal/revisions_logging_decorator.h +++ b/google/cloud/run/v2/internal/revisions_logging_decorator.h @@ -57,6 +57,22 @@ class RevisionsLogging : public RevisionsStub { grpc::ClientContext& context, Options options, google::cloud::run::v2::DeleteRevisionRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/run/v2/internal/revisions_metadata_decorator.cc b/google/cloud/run/v2/internal/revisions_metadata_decorator.cc index 6cf40e89eb848..f2554e961d6e7 100644 --- a/google/cloud/run/v2/internal/revisions_metadata_decorator.cc +++ b/google/cloud/run/v2/internal/revisions_metadata_decorator.cc @@ -159,6 +159,38 @@ StatusOr RevisionsMetadata::DeleteRevision( return child_->DeleteRevision(context, options, request); } +StatusOr +RevisionsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr RevisionsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status RevisionsMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +StatusOr RevisionsMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(context, options, request); +} + future> RevisionsMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/run/v2/internal/revisions_metadata_decorator.h b/google/cloud/run/v2/internal/revisions_metadata_decorator.h index e44384b21a7cf..63305f405a640 100644 --- a/google/cloud/run/v2/internal/revisions_metadata_decorator.h +++ b/google/cloud/run/v2/internal/revisions_metadata_decorator.h @@ -57,6 +57,22 @@ class RevisionsMetadata : public RevisionsStub { grpc::ClientContext& context, Options options, google::cloud::run::v2::DeleteRevisionRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/run/v2/internal/revisions_stub.cc b/google/cloud/run/v2/internal/revisions_stub.cc index 5d92e30e19b36..e74acc9bc9fa6 100644 --- a/google/cloud/run/v2/internal/revisions_stub.cc +++ b/google/cloud/run/v2/internal/revisions_stub.cc @@ -83,6 +83,51 @@ StatusOr DefaultRevisionsStub::DeleteRevision( return response; } +StatusOr +DefaultRevisionsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultRevisionsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultRevisionsStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr DefaultRevisionsStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultRevisionsStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/run/v2/internal/revisions_stub.h b/google/cloud/run/v2/internal/revisions_stub.h index 3c07a1027008c..2aedd4163a96d 100644 --- a/google/cloud/run/v2/internal/revisions_stub.h +++ b/google/cloud/run/v2/internal/revisions_stub.h @@ -56,6 +56,22 @@ class RevisionsStub { grpc::ClientContext& context, Options options, google::cloud::run::v2::DeleteRevisionRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -74,9 +90,13 @@ class DefaultRevisionsStub : public RevisionsStub { DefaultRevisionsStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr GetRevision( grpc::ClientContext& context, Options const& options, @@ -96,6 +116,22 @@ class DefaultRevisionsStub : public RevisionsStub { grpc::ClientContext& context, Options options, google::cloud::run::v2::DeleteRevisionRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -110,6 +146,8 @@ class DefaultRevisionsStub : public RevisionsStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/run/v2/internal/revisions_stub_factory.cc b/google/cloud/run/v2/internal/revisions_stub_factory.cc index de522934a5011..4051c502b3dc4 100644 --- a/google/cloud/run/v2/internal/revisions_stub_factory.cc +++ b/google/cloud/run/v2/internal/revisions_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -43,8 +44,10 @@ std::shared_ptr CreateDefaultRevisionsStub( auto channel = auth->CreateChannel(options.get(), internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::run::v2::Revisions::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/run/v2/internal/revisions_tracing_connection.cc b/google/cloud/run/v2/internal/revisions_tracing_connection.cc index 22ce3e3d943ac..b09e5a6e2e817 100644 --- a/google/cloud/run/v2/internal/revisions_tracing_connection.cc +++ b/google/cloud/run/v2/internal/revisions_tracing_connection.cc @@ -76,6 +76,40 @@ RevisionsTracingConnection::DeleteRevision( return internal::EndSpan(std::move(span), child_->DeleteRevision(operation)); } +StreamRange +RevisionsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan("run_v2::RevisionsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +RevisionsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan("run_v2::RevisionsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status RevisionsTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = + internal::MakeSpan("run_v2::RevisionsConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +StatusOr +RevisionsTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan("run_v2::RevisionsConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeRevisionsTracingConnection( diff --git a/google/cloud/run/v2/internal/revisions_tracing_connection.h b/google/cloud/run/v2/internal/revisions_tracing_connection.h index b97cfa14b096d..d8e9452fa01e5 100644 --- a/google/cloud/run/v2/internal/revisions_tracing_connection.h +++ b/google/cloud/run/v2/internal/revisions_tracing_connection.h @@ -55,6 +55,18 @@ class RevisionsTracingConnection : public run_v2::RevisionsConnection { future> DeleteRevision( google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/run/v2/internal/revisions_tracing_stub.cc b/google/cloud/run/v2/internal/revisions_tracing_stub.cc index 126ea58976b0e..91598a92cd0bb 100644 --- a/google/cloud/run/v2/internal/revisions_tracing_stub.cc +++ b/google/cloud/run/v2/internal/revisions_tracing_stub.cc @@ -80,6 +80,51 @@ StatusOr RevisionsTracingStub::DeleteRevision( child_->DeleteRevision(context, options, request)); } +StatusOr +RevisionsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.run.v2.Revisions", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr RevisionsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.run.v2.Revisions", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status RevisionsTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.run.v2.Revisions", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +StatusOr RevisionsTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.run.v2.Revisions", "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(context, options, request)); +} + future> RevisionsTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/run/v2/internal/revisions_tracing_stub.h b/google/cloud/run/v2/internal/revisions_tracing_stub.h index aecd9f721b14b..8a50b99766932 100644 --- a/google/cloud/run/v2/internal/revisions_tracing_stub.h +++ b/google/cloud/run/v2/internal/revisions_tracing_stub.h @@ -56,6 +56,22 @@ class RevisionsTracingStub : public RevisionsStub { grpc::ClientContext& context, Options options, google::cloud::run::v2::DeleteRevisionRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/run/v2/internal/services_auth_decorator.cc b/google/cloud/run/v2/internal/services_auth_decorator.cc index 57069424f46e6..fc1e84a331090 100644 --- a/google/cloud/run/v2/internal/services_auth_decorator.cc +++ b/google/cloud/run/v2/internal/services_auth_decorator.cc @@ -157,6 +157,39 @@ ServicesAuth::TestIamPermissions( return child_->TestIamPermissions(context, options, request); } +StatusOr +ServicesAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr ServicesAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status ServicesAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +StatusOr ServicesAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(context, options, request); +} + future> ServicesAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/run/v2/internal/services_auth_decorator.h b/google/cloud/run/v2/internal/services_auth_decorator.h index e5255b0764707..cf7692013a01c 100644 --- a/google/cloud/run/v2/internal/services_auth_decorator.h +++ b/google/cloud/run/v2/internal/services_auth_decorator.h @@ -89,6 +89,22 @@ class ServicesAuth : public ServicesStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/run/v2/internal/services_connection_impl.cc b/google/cloud/run/v2/internal/services_connection_impl.cc index fe27004d8b5f7..fda5559c783b4 100644 --- a/google/cloud/run/v2/internal/services_connection_impl.cc +++ b/google/cloud/run/v2/internal/services_connection_impl.cc @@ -409,6 +409,78 @@ ServicesConnectionImpl::TestIamPermissions( *current, request, __func__); } +StreamRange +ServicesConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr ServicesConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status ServicesConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr ServicesConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace run_v2_internal } // namespace cloud diff --git a/google/cloud/run/v2/internal/services_connection_impl.h b/google/cloud/run/v2/internal/services_connection_impl.h index c72e3c5790519..073e2d8dd1d2e 100644 --- a/google/cloud/run/v2/internal/services_connection_impl.h +++ b/google/cloud/run/v2/internal/services_connection_impl.h @@ -95,6 +95,18 @@ class ServicesConnectionImpl : public run_v2::ServicesConnection { StatusOr TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/run/v2/internal/services_logging_decorator.cc b/google/cloud/run/v2/internal/services_logging_decorator.cc index fa95e6ab43f96..34e23bff120e1 100644 --- a/google/cloud/run/v2/internal/services_logging_decorator.cc +++ b/google/cloud/run/v2/internal/services_logging_decorator.cc @@ -179,6 +179,51 @@ ServicesLogging::TestIamPermissions( context, options, request, __func__, tracing_options_); } +StatusOr +ServicesLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ServicesLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status ServicesLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ServicesLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> ServicesLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/run/v2/internal/services_logging_decorator.h b/google/cloud/run/v2/internal/services_logging_decorator.h index fa31b6344be2a..c1e54a1b202cc 100644 --- a/google/cloud/run/v2/internal/services_logging_decorator.h +++ b/google/cloud/run/v2/internal/services_logging_decorator.h @@ -89,6 +89,22 @@ class ServicesLogging : public ServicesStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/run/v2/internal/services_metadata_decorator.cc b/google/cloud/run/v2/internal/services_metadata_decorator.cc index d5ce7d4120c83..d0506876bf3ab 100644 --- a/google/cloud/run/v2/internal/services_metadata_decorator.cc +++ b/google/cloud/run/v2/internal/services_metadata_decorator.cc @@ -303,6 +303,38 @@ ServicesMetadata::TestIamPermissions( return child_->TestIamPermissions(context, options, request); } +StatusOr +ServicesMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr ServicesMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status ServicesMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +StatusOr ServicesMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(context, options, request); +} + future> ServicesMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/run/v2/internal/services_metadata_decorator.h b/google/cloud/run/v2/internal/services_metadata_decorator.h index 96f27bb5eec1e..1678c9d73f02d 100644 --- a/google/cloud/run/v2/internal/services_metadata_decorator.h +++ b/google/cloud/run/v2/internal/services_metadata_decorator.h @@ -89,6 +89,22 @@ class ServicesMetadata : public ServicesStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/run/v2/internal/services_stub.cc b/google/cloud/run/v2/internal/services_stub.cc index e842e383f430e..11ab8eccb7992 100644 --- a/google/cloud/run/v2/internal/services_stub.cc +++ b/google/cloud/run/v2/internal/services_stub.cc @@ -175,6 +175,51 @@ DefaultServicesStub::TestIamPermissions( return response; } +StatusOr +DefaultServicesStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultServicesStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultServicesStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr DefaultServicesStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultServicesStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/run/v2/internal/services_stub.h b/google/cloud/run/v2/internal/services_stub.h index 378e3a3f84788..5e26d41dff31c 100644 --- a/google/cloud/run/v2/internal/services_stub.h +++ b/google/cloud/run/v2/internal/services_stub.h @@ -89,6 +89,22 @@ class ServicesStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -107,9 +123,13 @@ class DefaultServicesStub : public ServicesStub { DefaultServicesStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateService( google::cloud::CompletionQueue& cq, @@ -161,6 +181,22 @@ class DefaultServicesStub : public ServicesStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -175,6 +211,8 @@ class DefaultServicesStub : public ServicesStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/run/v2/internal/services_stub_factory.cc b/google/cloud/run/v2/internal/services_stub_factory.cc index c8fb57e953857..56e5be5b918f5 100644 --- a/google/cloud/run/v2/internal/services_stub_factory.cc +++ b/google/cloud/run/v2/internal/services_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -43,8 +44,10 @@ std::shared_ptr CreateDefaultServicesStub( auto channel = auth->CreateChannel(options.get(), internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::run::v2::Services::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/run/v2/internal/services_tracing_connection.cc b/google/cloud/run/v2/internal/services_tracing_connection.cc index 4449b597711bb..38938fb7b26f6 100644 --- a/google/cloud/run/v2/internal/services_tracing_connection.cc +++ b/google/cloud/run/v2/internal/services_tracing_connection.cc @@ -145,6 +145,39 @@ ServicesTracingConnection::TestIamPermissions( return internal::EndSpan(*span, child_->TestIamPermissions(request)); } +StreamRange +ServicesTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan("run_v2::ServicesConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ServicesTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan("run_v2::ServicesConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status ServicesTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan("run_v2::ServicesConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +StatusOr +ServicesTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan("run_v2::ServicesConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeServicesTracingConnection( diff --git a/google/cloud/run/v2/internal/services_tracing_connection.h b/google/cloud/run/v2/internal/services_tracing_connection.h index 13fbd1e2cacd6..f592d61140e05 100644 --- a/google/cloud/run/v2/internal/services_tracing_connection.h +++ b/google/cloud/run/v2/internal/services_tracing_connection.h @@ -84,6 +84,18 @@ class ServicesTracingConnection : public run_v2::ServicesConnection { StatusOr TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/run/v2/internal/services_tracing_stub.cc b/google/cloud/run/v2/internal/services_tracing_stub.cc index 19c6e32d0b1b3..d5a6d529c5505 100644 --- a/google/cloud/run/v2/internal/services_tracing_stub.cc +++ b/google/cloud/run/v2/internal/services_tracing_stub.cc @@ -163,6 +163,51 @@ ServicesTracingStub::TestIamPermissions( context, *span, child_->TestIamPermissions(context, options, request)); } +StatusOr +ServicesTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.run.v2.Services", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr ServicesTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.run.v2.Services", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status ServicesTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.run.v2.Services", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +StatusOr ServicesTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.run.v2.Services", "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(context, options, request)); +} + future> ServicesTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/run/v2/internal/services_tracing_stub.h b/google/cloud/run/v2/internal/services_tracing_stub.h index e216810edf9ad..6d04b263bdd8d 100644 --- a/google/cloud/run/v2/internal/services_tracing_stub.h +++ b/google/cloud/run/v2/internal/services_tracing_stub.h @@ -88,6 +88,22 @@ class ServicesTracingStub : public ServicesStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/run/v2/internal/tasks_auth_decorator.cc b/google/cloud/run/v2/internal/tasks_auth_decorator.cc index 8a69d7e4f9e8e..a29dd3084fe7c 100644 --- a/google/cloud/run/v2/internal/tasks_auth_decorator.cc +++ b/google/cloud/run/v2/internal/tasks_auth_decorator.cc @@ -47,6 +47,38 @@ StatusOr TasksAuth::ListTasks( return child_->ListTasks(context, options, request); } +StatusOr TasksAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr TasksAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status TasksAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +StatusOr TasksAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace run_v2_internal } // namespace cloud diff --git a/google/cloud/run/v2/internal/tasks_auth_decorator.h b/google/cloud/run/v2/internal/tasks_auth_decorator.h index 8847881b826fb..9c681f7d2582f 100644 --- a/google/cloud/run/v2/internal/tasks_auth_decorator.h +++ b/google/cloud/run/v2/internal/tasks_auth_decorator.h @@ -46,6 +46,22 @@ class TasksAuth : public TasksStub { grpc::ClientContext& context, Options const& options, google::cloud::run::v2::ListTasksRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/run/v2/internal/tasks_connection_impl.cc b/google/cloud/run/v2/internal/tasks_connection_impl.cc index d59fe591f0fa8..833a6cd01cf02 100644 --- a/google/cloud/run/v2/internal/tasks_connection_impl.cc +++ b/google/cloud/run/v2/internal/tasks_connection_impl.cc @@ -99,6 +99,77 @@ StreamRange TasksConnectionImpl::ListTasks( }); } +StreamRange TasksConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr TasksConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status TasksConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr TasksConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace run_v2_internal } // namespace cloud diff --git a/google/cloud/run/v2/internal/tasks_connection_impl.h b/google/cloud/run/v2/internal/tasks_connection_impl.h index 831ab0195c403..31d7a8795da7a 100644 --- a/google/cloud/run/v2/internal/tasks_connection_impl.h +++ b/google/cloud/run/v2/internal/tasks_connection_impl.h @@ -53,6 +53,18 @@ class TasksConnectionImpl : public run_v2::TasksConnection { StreamRange ListTasks( google::cloud::run::v2::ListTasksRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/run/v2/internal/tasks_logging_decorator.cc b/google/cloud/run/v2/internal/tasks_logging_decorator.cc index 2bb7f8316ef62..017961e18d01d 100644 --- a/google/cloud/run/v2/internal/tasks_logging_decorator.cc +++ b/google/cloud/run/v2/internal/tasks_logging_decorator.cc @@ -57,6 +57,51 @@ StatusOr TasksLogging::ListTasks( context, options, request, __func__, tracing_options_); } +StatusOr +TasksLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr TasksLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status TasksLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr TasksLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace run_v2_internal } // namespace cloud diff --git a/google/cloud/run/v2/internal/tasks_logging_decorator.h b/google/cloud/run/v2/internal/tasks_logging_decorator.h index d1129aae10f06..e712b4d7369d1 100644 --- a/google/cloud/run/v2/internal/tasks_logging_decorator.h +++ b/google/cloud/run/v2/internal/tasks_logging_decorator.h @@ -45,6 +45,22 @@ class TasksLogging : public TasksStub { grpc::ClientContext& context, Options const& options, google::cloud::run::v2::ListTasksRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/run/v2/internal/tasks_metadata_decorator.cc b/google/cloud/run/v2/internal/tasks_metadata_decorator.cc index ebda33736724d..aa5d2f265ef80 100644 --- a/google/cloud/run/v2/internal/tasks_metadata_decorator.cc +++ b/google/cloud/run/v2/internal/tasks_metadata_decorator.cc @@ -60,6 +60,38 @@ StatusOr TasksMetadata::ListTasks( return child_->ListTasks(context, options, request); } +StatusOr +TasksMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr TasksMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status TasksMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +StatusOr TasksMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(context, options, request); +} + void TasksMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/run/v2/internal/tasks_metadata_decorator.h b/google/cloud/run/v2/internal/tasks_metadata_decorator.h index eae8f3cf9accb..3a7465740290d 100644 --- a/google/cloud/run/v2/internal/tasks_metadata_decorator.h +++ b/google/cloud/run/v2/internal/tasks_metadata_decorator.h @@ -46,6 +46,22 @@ class TasksMetadata : public TasksStub { grpc::ClientContext& context, Options const& options, google::cloud::run::v2::ListTasksRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/run/v2/internal/tasks_stub.cc b/google/cloud/run/v2/internal/tasks_stub.cc index 3be996c6fba26..140a225d3265d 100644 --- a/google/cloud/run/v2/internal/tasks_stub.cc +++ b/google/cloud/run/v2/internal/tasks_stub.cc @@ -52,6 +52,51 @@ StatusOr DefaultTasksStub::ListTasks( return response; } +StatusOr +DefaultTasksStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultTasksStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultTasksStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr DefaultTasksStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace run_v2_internal } // namespace cloud diff --git a/google/cloud/run/v2/internal/tasks_stub.h b/google/cloud/run/v2/internal/tasks_stub.h index 2eacae6d94f0b..fad496b1f463e 100644 --- a/google/cloud/run/v2/internal/tasks_stub.h +++ b/google/cloud/run/v2/internal/tasks_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -42,13 +43,32 @@ class TasksStub { virtual StatusOr ListTasks( grpc::ClientContext& context, Options const& options, google::cloud::run::v2::ListTasksRequest const& request) = 0; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; }; class DefaultTasksStub : public TasksStub { public: explicit DefaultTasksStub( - std::unique_ptr grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + std::unique_ptr grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr GetTask( grpc::ClientContext& context, Options const& options, @@ -58,8 +78,26 @@ class DefaultTasksStub : public TasksStub { grpc::ClientContext& context, Options const& options, google::cloud::run::v2::ListTasksRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/run/v2/internal/tasks_stub_factory.cc b/google/cloud/run/v2/internal/tasks_stub_factory.cc index 523626115d78e..712a090c80198 100644 --- a/google/cloud/run/v2/internal/tasks_stub_factory.cc +++ b/google/cloud/run/v2/internal/tasks_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -43,8 +44,10 @@ std::shared_ptr CreateDefaultTasksStub( auto channel = auth->CreateChannel(options.get(), internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::run::v2::Tasks::NewStub(channel); - std::shared_ptr stub = - std::make_shared(std::move(service_grpc_stub)); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); + std::shared_ptr stub = std::make_shared( + std::move(service_grpc_stub), std::move(service_operations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), std::move(stub)); diff --git a/google/cloud/run/v2/internal/tasks_tracing_connection.cc b/google/cloud/run/v2/internal/tasks_tracing_connection.cc index 6ac83d7546c05..4cf3c84000cce 100644 --- a/google/cloud/run/v2/internal/tasks_tracing_connection.cc +++ b/google/cloud/run/v2/internal/tasks_tracing_connection.cc @@ -49,6 +49,37 @@ StreamRange TasksTracingConnection::ListTasks( std::move(span), std::move(sr)); } +StreamRange +TasksTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan("run_v2::TasksConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr TasksTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan("run_v2::TasksConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status TasksTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan("run_v2::TasksConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +StatusOr TasksTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan("run_v2::TasksConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeTasksTracingConnection( diff --git a/google/cloud/run/v2/internal/tasks_tracing_connection.h b/google/cloud/run/v2/internal/tasks_tracing_connection.h index fc6b1069f1e23..870ced612e677 100644 --- a/google/cloud/run/v2/internal/tasks_tracing_connection.h +++ b/google/cloud/run/v2/internal/tasks_tracing_connection.h @@ -45,6 +45,18 @@ class TasksTracingConnection : public run_v2::TasksConnection { StreamRange ListTasks( google::cloud::run::v2::ListTasksRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/run/v2/internal/tasks_tracing_stub.cc b/google/cloud/run/v2/internal/tasks_tracing_stub.cc index a319d744df9ce..2ce99b4b7c0b5 100644 --- a/google/cloud/run/v2/internal/tasks_tracing_stub.cc +++ b/google/cloud/run/v2/internal/tasks_tracing_stub.cc @@ -51,6 +51,51 @@ StatusOr TasksTracingStub::ListTasks( child_->ListTasks(context, options, request)); } +StatusOr +TasksTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.run.v2.Tasks", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr TasksTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.run.v2.Tasks", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status TasksTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.run.v2.Tasks", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +StatusOr TasksTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.run.v2.Tasks", "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeTasksTracingStub( diff --git a/google/cloud/run/v2/internal/tasks_tracing_stub.h b/google/cloud/run/v2/internal/tasks_tracing_stub.h index e151fc46355c9..ab65a7d853384 100644 --- a/google/cloud/run/v2/internal/tasks_tracing_stub.h +++ b/google/cloud/run/v2/internal/tasks_tracing_stub.h @@ -46,6 +46,22 @@ class TasksTracingStub : public TasksStub { grpc::ClientContext& context, Options const& options, google::cloud::run::v2::ListTasksRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/run/v2/jobs_client.cc b/google/cloud/run/v2/jobs_client.cc index e4bbea8567617..3182a0e6a9f18 100644 --- a/google/cloud/run/v2/jobs_client.cc +++ b/google/cloud/run/v2/jobs_client.cc @@ -225,6 +225,54 @@ JobsClient::TestIamPermissions( return connection_->TestIamPermissions(request); } +StreamRange JobsClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange JobsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr JobsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr JobsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status JobsClient::DeleteOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status JobsClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +StatusOr JobsClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace run_v2 } // namespace cloud diff --git a/google/cloud/run/v2/jobs_client.h b/google/cloud/run/v2/jobs_client.h index 1f74821cca105..e8f612e119dd5 100644 --- a/google/cloud/run/v2/jobs_client.h +++ b/google/cloud/run/v2/jobs_client.h @@ -770,6 +770,252 @@ class JobsClient { google::iam::v1::TestIamPermissionsRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/run/v2/jobs_connection.cc b/google/cloud/run/v2/jobs_connection.cc index f242c4b4d7a45..f31c836dd1c1f 100644 --- a/google/cloud/run/v2/jobs_connection.cc +++ b/google/cloud/run/v2/jobs_connection.cc @@ -146,6 +146,28 @@ JobsConnection::TestIamPermissions( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange JobsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr JobsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status JobsConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr JobsConnection::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeJobsConnection(Options options) { internal::CheckExpectedOptions TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest const& request); }; /** diff --git a/google/cloud/run/v2/jobs_connection_idempotency_policy.cc b/google/cloud/run/v2/jobs_connection_idempotency_policy.cc index 72d7826bd2ee8..9f8234fd8ee8f 100644 --- a/google/cloud/run/v2/jobs_connection_idempotency_policy.cc +++ b/google/cloud/run/v2/jobs_connection_idempotency_policy.cc @@ -79,6 +79,26 @@ Idempotency JobsConnectionIdempotencyPolicy::TestIamPermissions( return Idempotency::kIdempotent; } +Idempotency JobsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency JobsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency JobsConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency JobsConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultJobsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/run/v2/jobs_connection_idempotency_policy.h b/google/cloud/run/v2/jobs_connection_idempotency_policy.h index 47554b291be3f..240b37d89f398 100644 --- a/google/cloud/run/v2/jobs_connection_idempotency_policy.h +++ b/google/cloud/run/v2/jobs_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,18 @@ class JobsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/run/v2/mocks/mock_executions_connection.h b/google/cloud/run/v2/mocks/mock_executions_connection.h index d2fe8df5f350a..375b5c41cf260 100644 --- a/google/cloud/run/v2/mocks/mock_executions_connection.h +++ b/google/cloud/run/v2/mocks/mock_executions_connection.h @@ -127,6 +127,21 @@ class MockExecutionsConnection : public run_v2::ExecutionsConnection { MOCK_METHOD(future>, CancelExecution, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/run/v2/mocks/mock_jobs_connection.h b/google/cloud/run/v2/mocks/mock_jobs_connection.h index 437d822f1c2fb..03de54a2bf391 100644 --- a/google/cloud/run/v2/mocks/mock_jobs_connection.h +++ b/google/cloud/run/v2/mocks/mock_jobs_connection.h @@ -201,6 +201,21 @@ class MockJobsConnection : public run_v2::JobsConnection { TestIamPermissions, (google::iam::v1::TestIamPermissionsRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/run/v2/mocks/mock_revisions_connection.h b/google/cloud/run/v2/mocks/mock_revisions_connection.h index ad76389d2b4b9..2c3be0f28f8c7 100644 --- a/google/cloud/run/v2/mocks/mock_revisions_connection.h +++ b/google/cloud/run/v2/mocks/mock_revisions_connection.h @@ -90,6 +90,21 @@ class MockRevisionsConnection : public run_v2::RevisionsConnection { MOCK_METHOD(future>, DeleteRevision, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/run/v2/mocks/mock_services_connection.h b/google/cloud/run/v2/mocks/mock_services_connection.h index 071584771684c..4b07d62ccf95c 100644 --- a/google/cloud/run/v2/mocks/mock_services_connection.h +++ b/google/cloud/run/v2/mocks/mock_services_connection.h @@ -171,6 +171,21 @@ class MockServicesConnection : public run_v2::ServicesConnection { TestIamPermissions, (google::iam::v1::TestIamPermissionsRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/run/v2/mocks/mock_tasks_connection.h b/google/cloud/run/v2/mocks/mock_tasks_connection.h index 4fe5777d1950f..8f69d018a6569 100644 --- a/google/cloud/run/v2/mocks/mock_tasks_connection.h +++ b/google/cloud/run/v2/mocks/mock_tasks_connection.h @@ -52,6 +52,21 @@ class MockTasksConnection : public run_v2::TasksConnection { MOCK_METHOD((StreamRange), ListTasks, (google::cloud::run::v2::ListTasksRequest request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/run/v2/revisions_client.cc b/google/cloud/run/v2/revisions_client.cc index 32dc25fc85400..07979b8df0fe3 100644 --- a/google/cloud/run/v2/revisions_client.cc +++ b/google/cloud/run/v2/revisions_client.cc @@ -98,6 +98,54 @@ RevisionsClient::DeleteRevision(google::longrunning::Operation const& operation, return connection_->DeleteRevision(operation); } +StreamRange RevisionsClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange RevisionsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr RevisionsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr RevisionsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status RevisionsClient::DeleteOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status RevisionsClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +StatusOr RevisionsClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace run_v2 } // namespace cloud diff --git a/google/cloud/run/v2/revisions_client.h b/google/cloud/run/v2/revisions_client.h index 27e4c46cba4f0..b04c78a60222e 100644 --- a/google/cloud/run/v2/revisions_client.h +++ b/google/cloud/run/v2/revisions_client.h @@ -335,6 +335,252 @@ class RevisionsClient { future> DeleteRevision( google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/run/v2/revisions_connection.cc b/google/cloud/run/v2/revisions_connection.cc index 28a84c9245710..daef7f807a6c7 100644 --- a/google/cloud/run/v2/revisions_connection.cc +++ b/google/cloud/run/v2/revisions_connection.cc @@ -72,6 +72,28 @@ RevisionsConnection::DeleteRevision(google::longrunning::Operation const&) { Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange RevisionsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr RevisionsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status RevisionsConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr RevisionsConnection::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeRevisionsConnection(Options options) { internal::CheckExpectedOptions> DeleteRevision( google::longrunning::Operation const& operation); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest const& request); }; /** diff --git a/google/cloud/run/v2/revisions_connection_idempotency_policy.cc b/google/cloud/run/v2/revisions_connection_idempotency_policy.cc index 782df266ae368..d1a201b13c85d 100644 --- a/google/cloud/run/v2/revisions_connection_idempotency_policy.cc +++ b/google/cloud/run/v2/revisions_connection_idempotency_policy.cc @@ -49,6 +49,26 @@ Idempotency RevisionsConnectionIdempotencyPolicy::DeleteRevision( return Idempotency::kNonIdempotent; } +Idempotency RevisionsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency RevisionsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency RevisionsConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency RevisionsConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultRevisionsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/run/v2/revisions_connection_idempotency_policy.h b/google/cloud/run/v2/revisions_connection_idempotency_policy.h index bf7619401bc65..985abf0b01fa2 100644 --- a/google/cloud/run/v2/revisions_connection_idempotency_policy.h +++ b/google/cloud/run/v2/revisions_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,18 @@ class RevisionsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteRevision( google::cloud::run::v2::DeleteRevisionRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/run/v2/services_client.cc b/google/cloud/run/v2/services_client.cc index f4665ce6a2683..3409afa376a88 100644 --- a/google/cloud/run/v2/services_client.cc +++ b/google/cloud/run/v2/services_client.cc @@ -211,6 +211,54 @@ ServicesClient::TestIamPermissions( return connection_->TestIamPermissions(request); } +StreamRange ServicesClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange ServicesClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr ServicesClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr ServicesClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status ServicesClient::DeleteOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status ServicesClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +StatusOr ServicesClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace run_v2 } // namespace cloud diff --git a/google/cloud/run/v2/services_client.h b/google/cloud/run/v2/services_client.h index 42c5607298bed..33b916e90a97a 100644 --- a/google/cloud/run/v2/services_client.h +++ b/google/cloud/run/v2/services_client.h @@ -713,6 +713,252 @@ class ServicesClient { google::iam::v1::TestIamPermissionsRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/run/v2/services_connection.cc b/google/cloud/run/v2/services_connection.cc index 4d42ea49a71ef..425c9a0bb4c0b 100644 --- a/google/cloud/run/v2/services_connection.cc +++ b/google/cloud/run/v2/services_connection.cc @@ -129,6 +129,28 @@ ServicesConnection::TestIamPermissions( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange ServicesConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr ServicesConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ServicesConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr ServicesConnection::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeServicesConnection(Options options) { internal::CheckExpectedOptions TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest const& request); }; /** diff --git a/google/cloud/run/v2/services_connection_idempotency_policy.cc b/google/cloud/run/v2/services_connection_idempotency_policy.cc index f4a4eac5e06b9..e6d4fa7c0a025 100644 --- a/google/cloud/run/v2/services_connection_idempotency_policy.cc +++ b/google/cloud/run/v2/services_connection_idempotency_policy.cc @@ -75,6 +75,26 @@ Idempotency ServicesConnectionIdempotencyPolicy::TestIamPermissions( return Idempotency::kIdempotent; } +Idempotency ServicesConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ServicesConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ServicesConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency ServicesConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultServicesConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/run/v2/services_connection_idempotency_policy.h b/google/cloud/run/v2/services_connection_idempotency_policy.h index 915d89d4b7f55..25e9c545e34e1 100644 --- a/google/cloud/run/v2/services_connection_idempotency_policy.h +++ b/google/cloud/run/v2/services_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,18 @@ class ServicesConnectionIdempotencyPolicy { virtual google::cloud::Idempotency TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/run/v2/tasks_client.cc b/google/cloud/run/v2/tasks_client.cc index a6870bbdc6a9c..3ff49665b2886 100644 --- a/google/cloud/run/v2/tasks_client.cc +++ b/google/cloud/run/v2/tasks_client.cc @@ -60,6 +60,54 @@ StreamRange TasksClient::ListTasks( return connection_->ListTasks(std::move(request)); } +StreamRange TasksClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange TasksClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr TasksClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr TasksClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status TasksClient::DeleteOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status TasksClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +StatusOr TasksClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace run_v2 } // namespace cloud diff --git a/google/cloud/run/v2/tasks_client.h b/google/cloud/run/v2/tasks_client.h index a452ce04ab237..227aa711a6320 100644 --- a/google/cloud/run/v2/tasks_client.h +++ b/google/cloud/run/v2/tasks_client.h @@ -217,6 +217,252 @@ class TasksClient { StreamRange ListTasks( google::cloud::run::v2::ListTasksRequest request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/run/v2/tasks_connection.cc b/google/cloud/run/v2/tasks_connection.cc index 27e3ff6ea4778..e65b2fa0c4b2f 100644 --- a/google/cloud/run/v2/tasks_connection.cc +++ b/google/cloud/run/v2/tasks_connection.cc @@ -50,6 +50,28 @@ StreamRange TasksConnection::ListTasks( StreamRange>(); } +StreamRange TasksConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr TasksConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status TasksConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr TasksConnection::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeTasksConnection(Options options) { internal::CheckExpectedOptions ListTasks( google::cloud::run::v2::ListTasksRequest request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest const& request); }; /** diff --git a/google/cloud/run/v2/tasks_connection_idempotency_policy.cc b/google/cloud/run/v2/tasks_connection_idempotency_policy.cc index d4024f134e287..193f8a686cc65 100644 --- a/google/cloud/run/v2/tasks_connection_idempotency_policy.cc +++ b/google/cloud/run/v2/tasks_connection_idempotency_policy.cc @@ -43,6 +43,26 @@ Idempotency TasksConnectionIdempotencyPolicy::ListTasks( return Idempotency::kIdempotent; } +Idempotency TasksConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency TasksConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency TasksConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency TasksConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultTasksConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/run/v2/tasks_connection_idempotency_policy.h b/google/cloud/run/v2/tasks_connection_idempotency_policy.h index 9774904e0ce68..5ba9ae37de252 100644 --- a/google/cloud/run/v2/tasks_connection_idempotency_policy.h +++ b/google/cloud/run/v2/tasks_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,18 @@ class TasksConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListTasks( google::cloud::run::v2::ListTasksRequest request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest const& request); }; std::unique_ptr 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 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..476a9c66244e9 100644 --- a/google/cloud/scheduler/v1/internal/cloud_scheduler_stub.h +++ b/google/cloud/scheduler/v1/internal/cloud_scheduler_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 @@ -66,6 +67,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 +83,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 +121,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..d910ac5d5f498 100644 --- a/google/cloud/secretmanager/v1/internal/secret_manager_stub.h +++ b/google/cloud/secretmanager/v1/internal/secret_manager_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 @@ -111,6 +112,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 +128,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 +210,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 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..8608a13dc80a3 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,82 @@ 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); +} + +StatusOr +SecureSourceManagerAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr SecureSourceManagerAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status SecureSourceManagerAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status SecureSourceManagerAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..66bc1e7a94299 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..cd5af8ce39de9 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,171 @@ 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__); +} + +StreamRange +SecureSourceManagerConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +SecureSourceManagerConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status SecureSourceManagerConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status SecureSourceManagerConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..5e2d4ee2b972a 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..795a131e7e6c3 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,110 @@ 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_); +} + +StatusOr +SecureSourceManagerLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +SecureSourceManagerLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status SecureSourceManagerLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status SecureSourceManagerLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..393491b817d99 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..ef02196ae1c73 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,86 @@ 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); +} + +StatusOr +SecureSourceManagerMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +SecureSourceManagerMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status SecureSourceManagerMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status SecureSourceManagerMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..ebdf1eebf0f05 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..ad6da3ce75866 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,111 @@ 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; +} + +StatusOr +DefaultSecureSourceManagerStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultSecureSourceManagerStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultSecureSourceManagerStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultSecureSourceManagerStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..f72789713c77d 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,9 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include +#include #include #include #include @@ -126,6 +128,44 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -145,9 +185,18 @@ class DefaultSecureSourceManagerStub : public SecureSourceManagerStub { std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListInstances( @@ -231,6 +280,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -247,6 +332,11 @@ class DefaultSecureSourceManagerStub : public SecureSourceManagerStub { std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..68baee23d5390 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,10 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include +#include +#include #include #include @@ -45,9 +48,15 @@ std::shared_ptr CreateDefaultSecureSourceManagerStub( auto service_grpc_stub = google::cloud::securesourcemanager::v1::SecureSourceManager::NewStub( channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..7384eace271f7 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,90 @@ 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)); +} + +StreamRange +SecureSourceManagerTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "securesourcemanager_v1::SecureSourceManagerConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +SecureSourceManagerTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "securesourcemanager_v1::SecureSourceManagerConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status SecureSourceManagerTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "securesourcemanager_v1::SecureSourceManagerConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status SecureSourceManagerTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "securesourcemanager_v1::SecureSourceManagerConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..6b5a7b6ae3f8f 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,33 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..27a511739e2a9 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,118 @@ 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)); +} + +StatusOr +SecureSourceManagerTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.securesourcemanager.v1.SecureSourceManager", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +SecureSourceManagerTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.securesourcemanager.v1.SecureSourceManager", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status SecureSourceManagerTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.securesourcemanager.v1.SecureSourceManager", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status SecureSourceManagerTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.securesourcemanager.v1.SecureSourceManager", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..e45e15b8dd358 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,42 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..e7090cac6d801 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,42 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..f5c6994d22e78 100644 --- a/google/cloud/securesourcemanager/v1/secure_source_manager_client.cc +++ b/google/cloud/securesourcemanager/v1/secure_source_manager_client.cc @@ -335,6 +335,100 @@ 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); +} + +StreamRange +SecureSourceManagerClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +SecureSourceManagerClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +SecureSourceManagerClient::GetOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +SecureSourceManagerClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status SecureSourceManagerClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status SecureSourceManagerClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status SecureSourceManagerClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status SecureSourceManagerClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..6870e9952632f 100644 --- a/google/cloud/securesourcemanager/v1/secure_source_manager_client.h +++ b/google/cloud/securesourcemanager/v1/secure_source_manager_client.h @@ -1043,6 +1043,458 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..e1ce12aa164c6 100644 --- a/google/cloud/securesourcemanager/v1/secure_source_manager_connection.cc +++ b/google/cloud/securesourcemanager/v1/secure_source_manager_connection.cc @@ -180,6 +180,60 @@ 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"); +} + +StreamRange +SecureSourceManagerConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +SecureSourceManagerConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status SecureSourceManagerConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status SecureSourceManagerConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSecureSourceManagerConnection(Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..96fcbedeb74f7 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,52 @@ 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; +} + +Idempotency SecureSourceManagerConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SecureSourceManagerConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency SecureSourceManagerConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency SecureSourceManagerConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..19efb8ad48b48 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,10 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include +#include #include namespace google { @@ -75,6 +78,33 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/securitycenter/v1/internal/security_center_auth_decorator.cc b/google/cloud/securitycenter/v1/internal/security_center_auth_decorator.cc index 2f8619f422908..c19357e2d6d7a 100644 --- a/google/cloud/securitycenter/v1/internal/security_center_auth_decorator.cc +++ b/google/cloud/securitycenter/v1/internal/security_center_auth_decorator.cc @@ -699,6 +699,39 @@ SecurityCenterAuth::ListAttackPaths( return child_->ListAttackPaths(context, options, request); } +StatusOr +SecurityCenterAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr SecurityCenterAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status SecurityCenterAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status SecurityCenterAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + future> SecurityCenterAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/securitycenter/v1/internal/security_center_auth_decorator.h b/google/cloud/securitycenter/v1/internal/security_center_auth_decorator.h index 47f8734bab2f9..87e661281d567 100644 --- a/google/cloud/securitycenter/v1/internal/security_center_auth_decorator.h +++ b/google/cloud/securitycenter/v1/internal/security_center_auth_decorator.h @@ -429,6 +429,22 @@ class SecurityCenterAuth : public SecurityCenterStub { google::cloud::securitycenter::v1::ListAttackPathsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/securitycenter/v1/internal/security_center_connection_impl.cc b/google/cloud/securitycenter/v1/internal/security_center_connection_impl.cc index 15eab3c6c0aa8..da35f2cc0915e 100644 --- a/google/cloud/securitycenter/v1/internal/security_center_connection_impl.cc +++ b/google/cloud/securitycenter/v1/internal/security_center_connection_impl.cc @@ -1630,6 +1630,79 @@ SecurityCenterConnectionImpl::ListAttackPaths( }); } +StreamRange +SecurityCenterConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +SecurityCenterConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status SecurityCenterConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status SecurityCenterConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace securitycenter_v1_internal } // namespace cloud diff --git a/google/cloud/securitycenter/v1/internal/security_center_connection_impl.h b/google/cloud/securitycenter/v1/internal/security_center_connection_impl.h index bc318d399d52a..e2a5bb014cdb3 100644 --- a/google/cloud/securitycenter/v1/internal/security_center_connection_impl.h +++ b/google/cloud/securitycenter/v1/internal/security_center_connection_impl.h @@ -379,6 +379,18 @@ class SecurityCenterConnectionImpl google::cloud::securitycenter::v1::ListAttackPathsRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/securitycenter/v1/internal/security_center_logging_decorator.cc b/google/cloud/securitycenter/v1/internal/security_center_logging_decorator.cc index 0ade65c2bb433..416c5c2f6dfe0 100644 --- a/google/cloud/securitycenter/v1/internal/security_center_logging_decorator.cc +++ b/google/cloud/securitycenter/v1/internal/security_center_logging_decorator.cc @@ -974,6 +974,51 @@ SecurityCenterLogging::ListAttackPaths( context, options, request, __func__, tracing_options_); } +StatusOr +SecurityCenterLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr SecurityCenterLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status SecurityCenterLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status SecurityCenterLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> SecurityCenterLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/securitycenter/v1/internal/security_center_logging_decorator.h b/google/cloud/securitycenter/v1/internal/security_center_logging_decorator.h index b68ad8ad02118..aef83ffc98951 100644 --- a/google/cloud/securitycenter/v1/internal/security_center_logging_decorator.h +++ b/google/cloud/securitycenter/v1/internal/security_center_logging_decorator.h @@ -429,6 +429,22 @@ class SecurityCenterLogging : public SecurityCenterStub { google::cloud::securitycenter::v1::ListAttackPathsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/securitycenter/v1/internal/security_center_metadata_decorator.cc b/google/cloud/securitycenter/v1/internal/security_center_metadata_decorator.cc index 4a2c71016f883..67b130e2c3b81 100644 --- a/google/cloud/securitycenter/v1/internal/security_center_metadata_decorator.cc +++ b/google/cloud/securitycenter/v1/internal/security_center_metadata_decorator.cc @@ -723,6 +723,39 @@ SecurityCenterMetadata::ListAttackPaths( return child_->ListAttackPaths(context, options, request); } +StatusOr +SecurityCenterMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr SecurityCenterMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status SecurityCenterMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status SecurityCenterMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + future> SecurityCenterMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/securitycenter/v1/internal/security_center_metadata_decorator.h b/google/cloud/securitycenter/v1/internal/security_center_metadata_decorator.h index b91122f2e6ad3..5980fd8d9a8f8 100644 --- a/google/cloud/securitycenter/v1/internal/security_center_metadata_decorator.h +++ b/google/cloud/securitycenter/v1/internal/security_center_metadata_decorator.h @@ -429,6 +429,22 @@ class SecurityCenterMetadata : public SecurityCenterStub { google::cloud::securitycenter::v1::ListAttackPathsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/securitycenter/v1/internal/security_center_stub.cc b/google/cloud/securitycenter/v1/internal/security_center_stub.cc index a72529a11bdd6..69f1c41c81aa4 100644 --- a/google/cloud/securitycenter/v1/internal/security_center_stub.cc +++ b/google/cloud/securitycenter/v1/internal/security_center_stub.cc @@ -914,6 +914,52 @@ DefaultSecurityCenterStub::ListAttackPaths( return response; } +StatusOr +DefaultSecurityCenterStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultSecurityCenterStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultSecurityCenterStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultSecurityCenterStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + future> DefaultSecurityCenterStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/securitycenter/v1/internal/security_center_stub.h b/google/cloud/securitycenter/v1/internal/security_center_stub.h index 14572845673e3..eaa3f27bd3708 100644 --- a/google/cloud/securitycenter/v1/internal/security_center_stub.h +++ b/google/cloud/securitycenter/v1/internal/security_center_stub.h @@ -433,6 +433,22 @@ class SecurityCenterStub { google::cloud::securitycenter::v1::ListAttackPathsRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -452,9 +468,13 @@ class DefaultSecurityCenterStub : public SecurityCenterStub { std::unique_ptr< google::cloud::securitycenter::v1::SecurityCenter::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} future> AsyncBulkMuteFindings( google::cloud::CompletionQueue& cq, @@ -846,6 +866,22 @@ class DefaultSecurityCenterStub : public SecurityCenterStub { google::cloud::securitycenter::v1::ListAttackPathsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -862,6 +898,8 @@ class DefaultSecurityCenterStub : public SecurityCenterStub { std::unique_ptr< google::cloud::securitycenter::v1::SecurityCenter::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/securitycenter/v1/internal/security_center_stub_factory.cc b/google/cloud/securitycenter/v1/internal/security_center_stub_factory.cc index e6f5fbdee31de..bfb62337f93c3 100644 --- a/google/cloud/securitycenter/v1/internal/security_center_stub_factory.cc +++ b/google/cloud/securitycenter/v1/internal/security_center_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 CreateDefaultSecurityCenterStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::securitycenter::v1::SecurityCenter::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/securitycenter/v1/internal/security_center_tracing_connection.cc b/google/cloud/securitycenter/v1/internal/security_center_tracing_connection.cc index 49b74854148d5..9cd3719a3d721 100644 --- a/google/cloud/securitycenter/v1/internal/security_center_tracing_connection.cc +++ b/google/cloud/securitycenter/v1/internal/security_center_tracing_connection.cc @@ -780,6 +780,42 @@ SecurityCenterTracingConnection::ListAttackPaths( std::move(sr)); } +StreamRange +SecurityCenterTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "securitycenter_v1::SecurityCenterConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +SecurityCenterTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "securitycenter_v1::SecurityCenterConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status SecurityCenterTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "securitycenter_v1::SecurityCenterConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status SecurityCenterTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "securitycenter_v1::SecurityCenterConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/securitycenter/v1/internal/security_center_tracing_connection.h b/google/cloud/securitycenter/v1/internal/security_center_tracing_connection.h index 0e27fcfe40dc5..84d81f11604cb 100644 --- a/google/cloud/securitycenter/v1/internal/security_center_tracing_connection.h +++ b/google/cloud/securitycenter/v1/internal/security_center_tracing_connection.h @@ -367,6 +367,18 @@ class SecurityCenterTracingConnection google::cloud::securitycenter::v1::ListAttackPathsRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/securitycenter/v1/internal/security_center_tracing_stub.cc b/google/cloud/securitycenter/v1/internal/security_center_tracing_stub.cc index 5f9474dca5a3a..f7ec9e3bfe555 100644 --- a/google/cloud/securitycenter/v1/internal/security_center_tracing_stub.cc +++ b/google/cloud/securitycenter/v1/internal/security_center_tracing_stub.cc @@ -927,6 +927,52 @@ SecurityCenterTracingStub::ListAttackPaths( child_->ListAttackPaths(context, options, request)); } +StatusOr +SecurityCenterTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.securitycenter.v1.SecurityCenter", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +SecurityCenterTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.securitycenter.v1.SecurityCenter", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status SecurityCenterTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.securitycenter.v1.SecurityCenter", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status SecurityCenterTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.securitycenter.v1.SecurityCenter", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + future> SecurityCenterTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/securitycenter/v1/internal/security_center_tracing_stub.h b/google/cloud/securitycenter/v1/internal/security_center_tracing_stub.h index 6c2c92bd686ea..e254e1ec7d0fa 100644 --- a/google/cloud/securitycenter/v1/internal/security_center_tracing_stub.h +++ b/google/cloud/securitycenter/v1/internal/security_center_tracing_stub.h @@ -428,6 +428,22 @@ class SecurityCenterTracingStub : public SecurityCenterStub { google::cloud::securitycenter::v1::ListAttackPathsRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/securitycenter/v1/mocks/mock_security_center_connection.h b/google/cloud/securitycenter/v1/mocks/mock_security_center_connection.h index 2065da0bd1267..eef5f0022f2a2 100644 --- a/google/cloud/securitycenter/v1/mocks/mock_security_center_connection.h +++ b/google/cloud/securitycenter/v1/mocks/mock_security_center_connection.h @@ -524,6 +524,21 @@ class MockSecurityCenterConnection ListAttackPaths, (google::cloud::securitycenter::v1::ListAttackPathsRequest request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/securitycenter/v1/security_center_client.cc b/google/cloud/securitycenter/v1/security_center_client.cc index 8e30f68ade119..decb6c638ff17 100644 --- a/google/cloud/securitycenter/v1/security_center_client.cc +++ b/google/cloud/securitycenter/v1/security_center_client.cc @@ -1313,6 +1313,65 @@ SecurityCenterClient::ListAttackPaths( return connection_->ListAttackPaths(std::move(request)); } +StreamRange +SecurityCenterClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +SecurityCenterClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr SecurityCenterClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr SecurityCenterClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status SecurityCenterClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status SecurityCenterClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status SecurityCenterClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status SecurityCenterClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace securitycenter_v1 } // namespace cloud diff --git a/google/cloud/securitycenter/v1/security_center_client.h b/google/cloud/securitycenter/v1/security_center_client.h index 52fb89a90ebd1..b6c74f912ab71 100644 --- a/google/cloud/securitycenter/v1/security_center_client.h +++ b/google/cloud/securitycenter/v1/security_center_client.h @@ -4523,6 +4523,286 @@ class SecurityCenterClient { google::cloud::securitycenter::v1::ListAttackPathsRequest request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/securitycenter/v1/security_center_connection.cc b/google/cloud/securitycenter/v1/security_center_connection.cc index 3d2d3c367c826..3f609af5ac7d3 100644 --- a/google/cloud/securitycenter/v1/security_center_connection.cc +++ b/google/cloud/securitycenter/v1/security_center_connection.cc @@ -511,6 +511,29 @@ SecurityCenterConnection::ListAttackPaths( StreamRange>(); } +StreamRange +SecurityCenterConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr SecurityCenterConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status SecurityCenterConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status SecurityCenterConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSecurityCenterConnection( Options options) { internal::CheckExpectedOptions ListAttackPaths( google::cloud::securitycenter::v1::ListAttackPathsRequest request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/securitycenter/v1/security_center_connection_idempotency_policy.cc b/google/cloud/securitycenter/v1/security_center_connection_idempotency_policy.cc index 25cfc70de835b..b4f3307dbf0b8 100644 --- a/google/cloud/securitycenter/v1/security_center_connection_idempotency_policy.cc +++ b/google/cloud/securitycenter/v1/security_center_connection_idempotency_policy.cc @@ -396,6 +396,26 @@ Idempotency SecurityCenterConnectionIdempotencyPolicy::ListAttackPaths( return Idempotency::kIdempotent; } +Idempotency SecurityCenterConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SecurityCenterConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency SecurityCenterConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency SecurityCenterConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultSecurityCenterConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/securitycenter/v1/security_center_connection_idempotency_policy.h b/google/cloud/securitycenter/v1/security_center_connection_idempotency_policy.h index 60bbbb84085cf..f635efe79ee01 100644 --- a/google/cloud/securitycenter/v1/security_center_connection_idempotency_policy.h +++ b/google/cloud/securitycenter/v1/security_center_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -275,6 +276,18 @@ class SecurityCenterConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListAttackPaths( google::cloud::securitycenter::v1::ListAttackPathsRequest request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/securitycenter/v2/internal/security_center_auth_decorator.cc b/google/cloud/securitycenter/v2/internal/security_center_auth_decorator.cc index d39cef99ccd70..ce468cb2cc479 100644 --- a/google/cloud/securitycenter/v2/internal/security_center_auth_decorator.cc +++ b/google/cloud/securitycenter/v2/internal/security_center_auth_decorator.cc @@ -424,6 +424,39 @@ SecurityCenterAuth::UpdateSource( return child_->UpdateSource(context, options, request); } +StatusOr +SecurityCenterAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr SecurityCenterAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status SecurityCenterAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status SecurityCenterAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + future> SecurityCenterAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/securitycenter/v2/internal/security_center_auth_decorator.h b/google/cloud/securitycenter/v2/internal/security_center_auth_decorator.h index 75a047d39b481..7167ed38f3a19 100644 --- a/google/cloud/securitycenter/v2/internal/security_center_auth_decorator.h +++ b/google/cloud/securitycenter/v2/internal/security_center_auth_decorator.h @@ -260,6 +260,22 @@ class SecurityCenterAuth : public SecurityCenterStub { google::cloud::securitycenter::v2::UpdateSourceRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/securitycenter/v2/internal/security_center_connection_impl.cc b/google/cloud/securitycenter/v2/internal/security_center_connection_impl.cc index 9750036ed19c2..e7294c5011f66 100644 --- a/google/cloud/securitycenter/v2/internal/security_center_connection_impl.cc +++ b/google/cloud/securitycenter/v2/internal/security_center_connection_impl.cc @@ -941,6 +941,79 @@ SecurityCenterConnectionImpl::UpdateSource( *current, request, __func__); } +StreamRange +SecurityCenterConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +SecurityCenterConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status SecurityCenterConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status SecurityCenterConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace securitycenter_v2_internal } // namespace cloud diff --git a/google/cloud/securitycenter/v2/internal/security_center_connection_impl.h b/google/cloud/securitycenter/v2/internal/security_center_connection_impl.h index 48ba176478f5a..301df2b0759d9 100644 --- a/google/cloud/securitycenter/v2/internal/security_center_connection_impl.h +++ b/google/cloud/securitycenter/v2/internal/security_center_connection_impl.h @@ -232,6 +232,18 @@ class SecurityCenterConnectionImpl google::cloud::securitycenter::v2::UpdateSourceRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/securitycenter/v2/internal/security_center_logging_decorator.cc b/google/cloud/securitycenter/v2/internal/security_center_logging_decorator.cc index 7bf3afef49fb9..d6c438fa5d6ee 100644 --- a/google/cloud/securitycenter/v2/internal/security_center_logging_decorator.cc +++ b/google/cloud/securitycenter/v2/internal/security_center_logging_decorator.cc @@ -593,6 +593,51 @@ SecurityCenterLogging::UpdateSource( context, options, request, __func__, tracing_options_); } +StatusOr +SecurityCenterLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr SecurityCenterLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status SecurityCenterLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status SecurityCenterLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> SecurityCenterLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/securitycenter/v2/internal/security_center_logging_decorator.h b/google/cloud/securitycenter/v2/internal/security_center_logging_decorator.h index 5fe086fd9ef7b..3d45e4b3e060f 100644 --- a/google/cloud/securitycenter/v2/internal/security_center_logging_decorator.h +++ b/google/cloud/securitycenter/v2/internal/security_center_logging_decorator.h @@ -260,6 +260,22 @@ class SecurityCenterLogging : public SecurityCenterStub { google::cloud::securitycenter::v2::UpdateSourceRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/securitycenter/v2/internal/security_center_metadata_decorator.cc b/google/cloud/securitycenter/v2/internal/security_center_metadata_decorator.cc index b3b74aabb2c39..0f67bbff60a22 100644 --- a/google/cloud/securitycenter/v2/internal/security_center_metadata_decorator.cc +++ b/google/cloud/securitycenter/v2/internal/security_center_metadata_decorator.cc @@ -594,6 +594,39 @@ SecurityCenterMetadata::UpdateSource( return child_->UpdateSource(context, options, request); } +StatusOr +SecurityCenterMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr SecurityCenterMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status SecurityCenterMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status SecurityCenterMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + future> SecurityCenterMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/securitycenter/v2/internal/security_center_metadata_decorator.h b/google/cloud/securitycenter/v2/internal/security_center_metadata_decorator.h index 4e8b092bef0df..00571e354992e 100644 --- a/google/cloud/securitycenter/v2/internal/security_center_metadata_decorator.h +++ b/google/cloud/securitycenter/v2/internal/security_center_metadata_decorator.h @@ -260,6 +260,22 @@ class SecurityCenterMetadata : public SecurityCenterStub { google::cloud::securitycenter::v2::UpdateSourceRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/securitycenter/v2/internal/security_center_stub.cc b/google/cloud/securitycenter/v2/internal/security_center_stub.cc index 956803ac0dd42..1577b4d39b54a 100644 --- a/google/cloud/securitycenter/v2/internal/security_center_stub.cc +++ b/google/cloud/securitycenter/v2/internal/security_center_stub.cc @@ -554,6 +554,52 @@ DefaultSecurityCenterStub::UpdateSource( return response; } +StatusOr +DefaultSecurityCenterStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultSecurityCenterStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultSecurityCenterStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultSecurityCenterStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + future> DefaultSecurityCenterStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/securitycenter/v2/internal/security_center_stub.h b/google/cloud/securitycenter/v2/internal/security_center_stub.h index 8e4e18371f651..37444f668215a 100644 --- a/google/cloud/securitycenter/v2/internal/security_center_stub.h +++ b/google/cloud/securitycenter/v2/internal/security_center_stub.h @@ -267,6 +267,22 @@ class SecurityCenterStub { google::cloud::securitycenter::v2::UpdateSourceRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -286,9 +302,13 @@ class DefaultSecurityCenterStub : public SecurityCenterStub { std::unique_ptr< google::cloud::securitycenter::v2::SecurityCenter::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr @@ -511,6 +531,22 @@ class DefaultSecurityCenterStub : public SecurityCenterStub { google::cloud::securitycenter::v2::UpdateSourceRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -527,6 +563,8 @@ class DefaultSecurityCenterStub : public SecurityCenterStub { std::unique_ptr< google::cloud::securitycenter::v2::SecurityCenter::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/securitycenter/v2/internal/security_center_stub_factory.cc b/google/cloud/securitycenter/v2/internal/security_center_stub_factory.cc index edad5cb456321..88ad6568c7c14 100644 --- a/google/cloud/securitycenter/v2/internal/security_center_stub_factory.cc +++ b/google/cloud/securitycenter/v2/internal/security_center_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 CreateDefaultSecurityCenterStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::securitycenter::v2::SecurityCenter::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/securitycenter/v2/internal/security_center_tracing_connection.cc b/google/cloud/securitycenter/v2/internal/security_center_tracing_connection.cc index 240b7b65ee11c..70293c612b27d 100644 --- a/google/cloud/securitycenter/v2/internal/security_center_tracing_connection.cc +++ b/google/cloud/securitycenter/v2/internal/security_center_tracing_connection.cc @@ -455,6 +455,42 @@ SecurityCenterTracingConnection::UpdateSource( return internal::EndSpan(*span, child_->UpdateSource(request)); } +StreamRange +SecurityCenterTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "securitycenter_v2::SecurityCenterConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +SecurityCenterTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "securitycenter_v2::SecurityCenterConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status SecurityCenterTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "securitycenter_v2::SecurityCenterConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status SecurityCenterTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "securitycenter_v2::SecurityCenterConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/securitycenter/v2/internal/security_center_tracing_connection.h b/google/cloud/securitycenter/v2/internal/security_center_tracing_connection.h index f99d4dd2f052e..85a35113c4d32 100644 --- a/google/cloud/securitycenter/v2/internal/security_center_tracing_connection.h +++ b/google/cloud/securitycenter/v2/internal/security_center_tracing_connection.h @@ -220,6 +220,18 @@ class SecurityCenterTracingConnection google::cloud::securitycenter::v2::UpdateSourceRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/securitycenter/v2/internal/security_center_tracing_stub.cc b/google/cloud/securitycenter/v2/internal/security_center_tracing_stub.cc index 0c15482507e0d..61263b2ebedfd 100644 --- a/google/cloud/securitycenter/v2/internal/security_center_tracing_stub.cc +++ b/google/cloud/securitycenter/v2/internal/security_center_tracing_stub.cc @@ -559,6 +559,52 @@ SecurityCenterTracingStub::UpdateSource( child_->UpdateSource(context, options, request)); } +StatusOr +SecurityCenterTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.securitycenter.v2.SecurityCenter", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +SecurityCenterTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.securitycenter.v2.SecurityCenter", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status SecurityCenterTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.securitycenter.v2.SecurityCenter", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status SecurityCenterTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.securitycenter.v2.SecurityCenter", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + future> SecurityCenterTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/securitycenter/v2/internal/security_center_tracing_stub.h b/google/cloud/securitycenter/v2/internal/security_center_tracing_stub.h index 438a1b18c7bb6..5ba5c2df21fde 100644 --- a/google/cloud/securitycenter/v2/internal/security_center_tracing_stub.h +++ b/google/cloud/securitycenter/v2/internal/security_center_tracing_stub.h @@ -259,6 +259,22 @@ class SecurityCenterTracingStub : public SecurityCenterStub { google::cloud::securitycenter::v2::UpdateSourceRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/securitycenter/v2/mocks/mock_security_center_connection.h b/google/cloud/securitycenter/v2/mocks/mock_security_center_connection.h index e35cfb36c1142..d123dd700b2f4 100644 --- a/google/cloud/securitycenter/v2/mocks/mock_security_center_connection.h +++ b/google/cloud/securitycenter/v2/mocks/mock_security_center_connection.h @@ -317,6 +317,21 @@ class MockSecurityCenterConnection StatusOr, UpdateSource, (google::cloud::securitycenter::v2::UpdateSourceRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/securitycenter/v2/security_center_client.cc b/google/cloud/securitycenter/v2/security_center_client.cc index 07586ecb7530e..6905e33bb208a 100644 --- a/google/cloud/securitycenter/v2/security_center_client.cc +++ b/google/cloud/securitycenter/v2/security_center_client.cc @@ -816,6 +816,65 @@ SecurityCenterClient::UpdateSource( return connection_->UpdateSource(request); } +StreamRange +SecurityCenterClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +SecurityCenterClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr SecurityCenterClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr SecurityCenterClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status SecurityCenterClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status SecurityCenterClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status SecurityCenterClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status SecurityCenterClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace securitycenter_v2 } // namespace cloud diff --git a/google/cloud/securitycenter/v2/security_center_client.h b/google/cloud/securitycenter/v2/security_center_client.h index 0c42d3608b91b..ec18a6a77b26a 100644 --- a/google/cloud/securitycenter/v2/security_center_client.h +++ b/google/cloud/securitycenter/v2/security_center_client.h @@ -2956,6 +2956,286 @@ class SecurityCenterClient { google::cloud::securitycenter::v2::UpdateSourceRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/securitycenter/v2/security_center_connection.cc b/google/cloud/securitycenter/v2/security_center_connection.cc index 171078dc0a32e..34aeb131cf43c 100644 --- a/google/cloud/securitycenter/v2/security_center_connection.cc +++ b/google/cloud/securitycenter/v2/security_center_connection.cc @@ -314,6 +314,29 @@ SecurityCenterConnection::UpdateSource( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +SecurityCenterConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr SecurityCenterConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status SecurityCenterConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status SecurityCenterConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSecurityCenterConnection( Options options) { internal::CheckExpectedOptions UpdateSource( google::cloud::securitycenter::v2::UpdateSourceRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/securitycenter/v2/security_center_connection_idempotency_policy.cc b/google/cloud/securitycenter/v2/security_center_connection_idempotency_policy.cc index 428e614c5c8a3..84d71eba75fe7 100644 --- a/google/cloud/securitycenter/v2/security_center_connection_idempotency_policy.cc +++ b/google/cloud/securitycenter/v2/security_center_connection_idempotency_policy.cc @@ -243,6 +243,26 @@ Idempotency SecurityCenterConnectionIdempotencyPolicy::UpdateSource( return Idempotency::kNonIdempotent; } +Idempotency SecurityCenterConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SecurityCenterConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency SecurityCenterConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency SecurityCenterConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultSecurityCenterConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/securitycenter/v2/security_center_connection_idempotency_policy.h b/google/cloud/securitycenter/v2/security_center_connection_idempotency_policy.h index fbc6f48d3bc2b..874334a29dfef 100644 --- a/google/cloud/securitycenter/v2/security_center_connection_idempotency_policy.h +++ b/google/cloud/securitycenter/v2/security_center_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -177,6 +178,18 @@ class SecurityCenterConnectionIdempotencyPolicy { virtual google::cloud::Idempotency UpdateSource( google::cloud::securitycenter::v2::UpdateSourceRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..4056c591eb945 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,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include #include @@ -187,6 +188,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 +205,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 +368,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 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..e28f7388a2f84 100644 --- a/google/cloud/servicedirectory/v1/internal/lookup_stub.h +++ b/google/cloud/servicedirectory/v1/internal/lookup_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 @@ -40,6 +41,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 +57,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 +69,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..1c8d79aa32041 100644 --- a/google/cloud/servicedirectory/v1/internal/registration_stub.h +++ b/google/cloud/servicedirectory/v1/internal/registration_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 @@ -127,6 +128,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 +144,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 +238,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 @@ -187,6 +188,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 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..734ae5dd6c3c6 100644 --- a/google/cloud/servicehealth/v1/internal/service_health_stub.h +++ b/google/cloud/servicehealth/v1/internal/service_health_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 @@ -69,6 +70,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 +86,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 +126,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 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..6afa8cf09e1f6 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,40 @@ 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); +} + +StatusOr +ServiceManagerAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(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..542f697b2ee82 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,22 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest 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..0820fbfd990ae 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,79 @@ 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__); +} + +StreamRange +ServiceManagerConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + 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..0bc6e894a8fb0 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,18 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest 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..1f93d7baefdee 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,52 @@ 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_); +} + +StatusOr +ServiceManagerLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(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..0d7b9982ae8ba 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,22 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest 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..5aa72efcbd0da 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,42 @@ 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); +} + +StatusOr +ServiceManagerMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, absl::StrCat()); + return child_->ListOperations(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..389ff63765554 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,22 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest 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..d24649d2d5376 100644 --- a/google/cloud/servicemanagement/v1/internal/service_manager_stub.cc +++ b/google/cloud/servicemanagement/v1/internal/service_manager_stub.cc @@ -292,6 +292,53 @@ 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; +} + +StatusOr +DefaultServiceManagerStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&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..2ed4be8e52745 100644 --- a/google/cloud/servicemanagement/v1/internal/service_manager_stub.h +++ b/google/cloud/servicemanagement/v1/internal/service_manager_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -147,6 +148,23 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -166,9 +184,15 @@ class DefaultServiceManagerStub : public ServiceManagerStub { std::unique_ptr< google::api::servicemanagement::v1::ServiceManager::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + operations_(std::move(operations)) {} StatusOr ListServices(grpc::ClientContext& context, Options const& options, @@ -273,6 +297,22 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -289,6 +329,9 @@ class DefaultServiceManagerStub : public ServiceManagerStub { std::unique_ptr< google::api::servicemanagement::v1::ServiceManager::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..57c54e776b702 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,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultServiceManagerStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::api::servicemanagement::v1::ServiceManager::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..78f6e7dbf31dd 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,42 @@ 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)); +} + +StreamRange +ServiceManagerTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "servicemanagement_v1::ServiceManagerConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(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/servicemanagement/v1/internal/service_manager_tracing_connection.h b/google/cloud/servicemanagement/v1/internal/service_manager_tracing_connection.h index a686f3517dfa1..8917a041898a5 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,18 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest 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..ba441f08574e6 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,52 @@ 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)); +} + +StatusOr +ServiceManagerTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.api.servicemanagement.v1.ServiceManager", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(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..a8c37bbc0af6c 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,22 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest 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..3381288b8c9f0 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,22 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest 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..4a16cc01e539e 100644 --- a/google/cloud/servicemanagement/v1/service_manager_client.cc +++ b/google/cloud/servicemanagement/v1/service_manager_client.cc @@ -391,6 +391,42 @@ 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); +} + +StreamRange +ServiceManagerClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +ServiceManagerClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(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..f531b7c632231 100644 --- a/google/cloud/servicemanagement/v1/service_manager_client.h +++ b/google/cloud/servicemanagement/v1/service_manager_client.h @@ -1362,6 +1362,200 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest 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..52fe5b1fbf011 100644 --- a/google/cloud/servicemanagement/v1/service_manager_connection.cc +++ b/google/cloud/servicemanagement/v1/service_manager_connection.cc @@ -207,6 +207,30 @@ 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"); +} + +StreamRange +ServiceManagerConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + std::shared_ptr MakeServiceManagerConnection( Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest 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..1b9baf3e59b40 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,27 @@ 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; +} + +Idempotency ServiceManagerConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + 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..336837dc80807 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,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -82,6 +84,18 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); }; std::unique_ptr diff --git a/google/cloud/serviceusage/v1/internal/service_usage_auth_decorator.cc b/google/cloud/serviceusage/v1/internal/service_usage_auth_decorator.cc index e98ca3ee0ddab..0a4032ac9d768 100644 --- a/google/cloud/serviceusage/v1/internal/service_usage_auth_decorator.cc +++ b/google/cloud/serviceusage/v1/internal/service_usage_auth_decorator.cc @@ -141,6 +141,23 @@ ServiceUsageAuth::BatchGetServices( return child_->BatchGetServices(context, options, request); } +StatusOr +ServiceUsageAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr ServiceUsageAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + future> ServiceUsageAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/serviceusage/v1/internal/service_usage_auth_decorator.h b/google/cloud/serviceusage/v1/internal/service_usage_auth_decorator.h index af1302ca2a34a..4f78fafbe0653 100644 --- a/google/cloud/serviceusage/v1/internal/service_usage_auth_decorator.h +++ b/google/cloud/serviceusage/v1/internal/service_usage_auth_decorator.h @@ -89,6 +89,14 @@ class ServiceUsageAuth : public ServiceUsageStub { google::api::serviceusage::v1::BatchGetServicesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/serviceusage/v1/internal/service_usage_connection_impl.cc b/google/cloud/serviceusage/v1/internal/service_usage_connection_impl.cc index ac3ae314d065a..3076ef45223f8 100644 --- a/google/cloud/serviceusage/v1/internal/service_usage_connection_impl.cc +++ b/google/cloud/serviceusage/v1/internal/service_usage_connection_impl.cc @@ -406,6 +406,53 @@ ServiceUsageConnectionImpl::BatchGetServices( *current, request, __func__); } +StreamRange +ServiceUsageConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ServiceUsageConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace serviceusage_v1_internal } // namespace cloud diff --git a/google/cloud/serviceusage/v1/internal/service_usage_connection_impl.h b/google/cloud/serviceusage/v1/internal/service_usage_connection_impl.h index 09d338380c1d5..b3f0b3f595e59 100644 --- a/google/cloud/serviceusage/v1/internal/service_usage_connection_impl.h +++ b/google/cloud/serviceusage/v1/internal/service_usage_connection_impl.h @@ -99,6 +99,12 @@ class ServiceUsageConnectionImpl BatchGetServices(google::api::serviceusage::v1::BatchGetServicesRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/serviceusage/v1/internal/service_usage_logging_decorator.cc b/google/cloud/serviceusage/v1/internal/service_usage_logging_decorator.cc index 48715cf1f4c5d..6fe5a02501ba5 100644 --- a/google/cloud/serviceusage/v1/internal/service_usage_logging_decorator.cc +++ b/google/cloud/serviceusage/v1/internal/service_usage_logging_decorator.cc @@ -167,6 +167,29 @@ ServiceUsageLogging::BatchGetServices( context, options, request, __func__, tracing_options_); } +StatusOr +ServiceUsageLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ServiceUsageLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> ServiceUsageLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/serviceusage/v1/internal/service_usage_logging_decorator.h b/google/cloud/serviceusage/v1/internal/service_usage_logging_decorator.h index c1452e8136f28..3150b4a3548c9 100644 --- a/google/cloud/serviceusage/v1/internal/service_usage_logging_decorator.h +++ b/google/cloud/serviceusage/v1/internal/service_usage_logging_decorator.h @@ -89,6 +89,14 @@ class ServiceUsageLogging : public ServiceUsageStub { google::api::serviceusage::v1::BatchGetServicesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/serviceusage/v1/internal/service_usage_metadata_decorator.cc b/google/cloud/serviceusage/v1/internal/service_usage_metadata_decorator.cc index deb13d66119da..b47374b8d7e36 100644 --- a/google/cloud/serviceusage/v1/internal/service_usage_metadata_decorator.cc +++ b/google/cloud/serviceusage/v1/internal/service_usage_metadata_decorator.cc @@ -132,6 +132,22 @@ ServiceUsageMetadata::BatchGetServices( return child_->BatchGetServices(context, options, request); } +StatusOr +ServiceUsageMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, absl::StrCat()); + return child_->ListOperations(context, options, request); +} + +StatusOr ServiceUsageMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + future> ServiceUsageMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/serviceusage/v1/internal/service_usage_metadata_decorator.h b/google/cloud/serviceusage/v1/internal/service_usage_metadata_decorator.h index 87715fa8bc9cb..cf920c014fbda 100644 --- a/google/cloud/serviceusage/v1/internal/service_usage_metadata_decorator.h +++ b/google/cloud/serviceusage/v1/internal/service_usage_metadata_decorator.h @@ -89,6 +89,14 @@ class ServiceUsageMetadata : public ServiceUsageStub { google::api::serviceusage::v1::BatchGetServicesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/serviceusage/v1/internal/service_usage_stub.cc b/google/cloud/serviceusage/v1/internal/service_usage_stub.cc index 336250533262f..4161e1ab495dc 100644 --- a/google/cloud/serviceusage/v1/internal/service_usage_stub.cc +++ b/google/cloud/serviceusage/v1/internal/service_usage_stub.cc @@ -158,6 +158,29 @@ DefaultServiceUsageStub::BatchGetServices( return response; } +StatusOr +DefaultServiceUsageStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultServiceUsageStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultServiceUsageStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/serviceusage/v1/internal/service_usage_stub.h b/google/cloud/serviceusage/v1/internal/service_usage_stub.h index c654ad1fb51b3..a27f4f49896af 100644 --- a/google/cloud/serviceusage/v1/internal/service_usage_stub.h +++ b/google/cloud/serviceusage/v1/internal/service_usage_stub.h @@ -85,6 +85,14 @@ class ServiceUsageStub { google::api::serviceusage::v1::BatchGetServicesRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -104,9 +112,13 @@ class DefaultServiceUsageStub : public ServiceUsageStub { std::unique_ptr< google::api::serviceusage::v1::ServiceUsage::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} future> AsyncEnableService( google::cloud::CompletionQueue& cq, @@ -158,6 +170,14 @@ class DefaultServiceUsageStub : public ServiceUsageStub { google::api::serviceusage::v1::BatchGetServicesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -173,6 +193,8 @@ class DefaultServiceUsageStub : public ServiceUsageStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/serviceusage/v1/internal/service_usage_stub_factory.cc b/google/cloud/serviceusage/v1/internal/service_usage_stub_factory.cc index 19be9a9eea7e4..99da1427e107d 100644 --- a/google/cloud/serviceusage/v1/internal/service_usage_stub_factory.cc +++ b/google/cloud/serviceusage/v1/internal/service_usage_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 CreateDefaultServiceUsageStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::api::serviceusage::v1::ServiceUsage::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/serviceusage/v1/internal/service_usage_tracing_connection.cc b/google/cloud/serviceusage/v1/internal/service_usage_tracing_connection.cc index 40f452dc4302d..bc43e2f579aaa 100644 --- a/google/cloud/serviceusage/v1/internal/service_usage_tracing_connection.cc +++ b/google/cloud/serviceusage/v1/internal/service_usage_tracing_connection.cc @@ -150,6 +150,26 @@ ServiceUsageTracingConnection::BatchGetServices( return internal::EndSpan(*span, child_->BatchGetServices(request)); } +StreamRange +ServiceUsageTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "serviceusage_v1::ServiceUsageConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ServiceUsageTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "serviceusage_v1::ServiceUsageConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/serviceusage/v1/internal/service_usage_tracing_connection.h b/google/cloud/serviceusage/v1/internal/service_usage_tracing_connection.h index ccd6273fa4f13..a209e18e344e4 100644 --- a/google/cloud/serviceusage/v1/internal/service_usage_tracing_connection.h +++ b/google/cloud/serviceusage/v1/internal/service_usage_tracing_connection.h @@ -87,6 +87,12 @@ class ServiceUsageTracingConnection BatchGetServices(google::api::serviceusage::v1::BatchGetServicesRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/serviceusage/v1/internal/service_usage_tracing_stub.cc b/google/cloud/serviceusage/v1/internal/service_usage_tracing_stub.cc index fa1b6da1d6eff..349cf6f8db76c 100644 --- a/google/cloud/serviceusage/v1/internal/service_usage_tracing_stub.cc +++ b/google/cloud/serviceusage/v1/internal/service_usage_tracing_stub.cc @@ -147,6 +147,29 @@ ServiceUsageTracingStub::BatchGetServices( child_->BatchGetServices(context, options, request)); } +StatusOr +ServiceUsageTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.api.serviceusage.v1.ServiceUsage", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr ServiceUsageTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.api.serviceusage.v1.ServiceUsage", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + future> ServiceUsageTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/serviceusage/v1/internal/service_usage_tracing_stub.h b/google/cloud/serviceusage/v1/internal/service_usage_tracing_stub.h index 367bcb72fac11..33a98ac435300 100644 --- a/google/cloud/serviceusage/v1/internal/service_usage_tracing_stub.h +++ b/google/cloud/serviceusage/v1/internal/service_usage_tracing_stub.h @@ -88,6 +88,14 @@ class ServiceUsageTracingStub : public ServiceUsageStub { google::api::serviceusage::v1::BatchGetServicesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/serviceusage/v1/mocks/mock_service_usage_connection.h b/google/cloud/serviceusage/v1/mocks/mock_service_usage_connection.h index 42055bd190c79..ae2d073614177 100644 --- a/google/cloud/serviceusage/v1/mocks/mock_service_usage_connection.h +++ b/google/cloud/serviceusage/v1/mocks/mock_service_usage_connection.h @@ -184,6 +184,13 @@ class MockServiceUsageConnection BatchGetServices, (google::api::serviceusage::v1::BatchGetServicesRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/serviceusage/v1/service_usage_client.cc b/google/cloud/serviceusage/v1/service_usage_client.cc index 4639573396b5b..c195a28949c3e 100644 --- a/google/cloud/serviceusage/v1/service_usage_client.cc +++ b/google/cloud/serviceusage/v1/service_usage_client.cc @@ -124,6 +124,35 @@ ServiceUsageClient::BatchGetServices( return connection_->BatchGetServices(request); } +StreamRange ServiceUsageClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange ServiceUsageClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr ServiceUsageClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr ServiceUsageClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace serviceusage_v1 } // namespace cloud diff --git a/google/cloud/serviceusage/v1/service_usage_client.h b/google/cloud/serviceusage/v1/service_usage_client.h index eec0951adf38b..b66d1c7f8b3bf 100644 --- a/google/cloud/serviceusage/v1/service_usage_client.h +++ b/google/cloud/serviceusage/v1/service_usage_client.h @@ -420,6 +420,158 @@ class ServiceUsageClient { google::api::serviceusage::v1::BatchGetServicesRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/serviceusage/v1/service_usage_connection.cc b/google/cloud/serviceusage/v1/service_usage_connection.cc index b1a997c3cd7a6..451d6dbf48b24 100644 --- a/google/cloud/serviceusage/v1/service_usage_connection.cc +++ b/google/cloud/serviceusage/v1/service_usage_connection.cc @@ -124,6 +124,19 @@ ServiceUsageConnection::BatchGetServices( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +ServiceUsageConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr ServiceUsageConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeServiceUsageConnection( Options options) { internal::CheckExpectedOptions BatchGetServices( google::api::serviceusage::v1::BatchGetServicesRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/serviceusage/v1/service_usage_connection_idempotency_policy.cc b/google/cloud/serviceusage/v1/service_usage_connection_idempotency_policy.cc index 5e1b698795dc3..658c89cdc7d58 100644 --- a/google/cloud/serviceusage/v1/service_usage_connection_idempotency_policy.cc +++ b/google/cloud/serviceusage/v1/service_usage_connection_idempotency_policy.cc @@ -64,6 +64,16 @@ Idempotency ServiceUsageConnectionIdempotencyPolicy::BatchGetServices( return Idempotency::kIdempotent; } +Idempotency ServiceUsageConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ServiceUsageConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultServiceUsageConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/serviceusage/v1/service_usage_connection_idempotency_policy.h b/google/cloud/serviceusage/v1/service_usage_connection_idempotency_policy.h index 02c42c2b961ca..f2162f9e3302f 100644 --- a/google/cloud/serviceusage/v1/service_usage_connection_idempotency_policy.h +++ b/google/cloud/serviceusage/v1/service_usage_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 ServiceUsageConnectionIdempotencyPolicy { virtual google::cloud::Idempotency BatchGetServices( google::api::serviceusage::v1::BatchGetServicesRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/spanner/admin/database_admin_client.cc b/google/cloud/spanner/admin/database_admin_client.cc index 508ed92e12f33..965928584f445 100644 --- a/google/cloud/spanner/admin/database_admin_client.cc +++ b/google/cloud/spanner/admin/database_admin_client.cc @@ -671,6 +671,63 @@ DatabaseAdminClient::ListBackupSchedules( return connection_->ListBackupSchedules(std::move(request)); } +StreamRange DatabaseAdminClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange DatabaseAdminClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr DatabaseAdminClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr DatabaseAdminClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status DatabaseAdminClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status DatabaseAdminClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status DatabaseAdminClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status DatabaseAdminClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner_admin } // namespace cloud diff --git a/google/cloud/spanner/admin/database_admin_client.h b/google/cloud/spanner/admin/database_admin_client.h index 7fe83ef9c93dd..faec0df7464ae 100644 --- a/google/cloud/spanner/admin/database_admin_client.h +++ b/google/cloud/spanner/admin/database_admin_client.h @@ -2428,6 +2428,286 @@ class DatabaseAdminClient { google::spanner::admin::database::v1::ListBackupSchedulesRequest request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/spanner/admin/database_admin_connection.cc b/google/cloud/spanner/admin/database_admin_connection.cc index 5bc3d120abfd9..87d8ff70aa1f6 100644 --- a/google/cloud/spanner/admin/database_admin_connection.cc +++ b/google/cloud/spanner/admin/database_admin_connection.cc @@ -299,6 +299,29 @@ DatabaseAdminConnection::ListBackupSchedules( StreamRange>(); } +StreamRange +DatabaseAdminConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr DatabaseAdminConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DatabaseAdminConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DatabaseAdminConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDatabaseAdminConnection( Options options) { internal::CheckExpectedOptions ListBackupSchedules( google::spanner::admin::database::v1::ListBackupSchedulesRequest request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/spanner/admin/database_admin_connection_idempotency_policy.cc b/google/cloud/spanner/admin/database_admin_connection_idempotency_policy.cc index 7a3b29b4eb240..e557056da19d5 100644 --- a/google/cloud/spanner/admin/database_admin_connection_idempotency_policy.cc +++ b/google/cloud/spanner/admin/database_admin_connection_idempotency_policy.cc @@ -163,6 +163,26 @@ Idempotency DatabaseAdminConnectionIdempotencyPolicy::ListBackupSchedules( return Idempotency::kIdempotent; } +Idempotency DatabaseAdminConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DatabaseAdminConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DatabaseAdminConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency DatabaseAdminConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultDatabaseAdminConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/spanner/admin/database_admin_connection_idempotency_policy.h b/google/cloud/spanner/admin/database_admin_connection_idempotency_policy.h index 6bad375e449d0..892b26188b2a7 100644 --- a/google/cloud/spanner/admin/database_admin_connection_idempotency_policy.h +++ b/google/cloud/spanner/admin/database_admin_connection_idempotency_policy.h @@ -21,6 +21,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -122,6 +123,18 @@ class DatabaseAdminConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListBackupSchedules( google::spanner::admin::database::v1::ListBackupSchedulesRequest request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/spanner/admin/internal/database_admin_auth_decorator.cc b/google/cloud/spanner/admin/internal/database_admin_auth_decorator.cc index 4dcbef5469c26..e32b22efc5f89 100644 --- a/google/cloud/spanner/admin/internal/database_admin_auth_decorator.cc +++ b/google/cloud/spanner/admin/internal/database_admin_auth_decorator.cc @@ -382,6 +382,39 @@ DatabaseAdminAuth::ListBackupSchedules( return child_->ListBackupSchedules(context, options, request); } +StatusOr +DatabaseAdminAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr DatabaseAdminAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status DatabaseAdminAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status DatabaseAdminAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + future> DatabaseAdminAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/spanner/admin/internal/database_admin_auth_decorator.h b/google/cloud/spanner/admin/internal/database_admin_auth_decorator.h index c17edd949495f..0294b097589a3 100644 --- a/google/cloud/spanner/admin/internal/database_admin_auth_decorator.h +++ b/google/cloud/spanner/admin/internal/database_admin_auth_decorator.h @@ -212,6 +212,22 @@ class DatabaseAdminAuth : public DatabaseAdminStub { google::spanner::admin::database::v1::ListBackupSchedulesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/spanner/admin/internal/database_admin_connection_impl.cc b/google/cloud/spanner/admin/internal/database_admin_connection_impl.cc index 18241aed7127f..599382b9918b8 100644 --- a/google/cloud/spanner/admin/internal/database_admin_connection_impl.cc +++ b/google/cloud/spanner/admin/internal/database_admin_connection_impl.cc @@ -1044,6 +1044,79 @@ DatabaseAdminConnectionImpl::ListBackupSchedules( }); } +StreamRange +DatabaseAdminConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DatabaseAdminConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DatabaseAdminConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DatabaseAdminConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner_admin_internal } // namespace cloud diff --git a/google/cloud/spanner/admin/internal/database_admin_connection_impl.h b/google/cloud/spanner/admin/internal/database_admin_connection_impl.h index 590131e77c952..46a29edacb311 100644 --- a/google/cloud/spanner/admin/internal/database_admin_connection_impl.h +++ b/google/cloud/spanner/admin/internal/database_admin_connection_impl.h @@ -209,6 +209,18 @@ class DatabaseAdminConnectionImpl google::spanner::admin::database::v1::ListBackupSchedulesRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/spanner/admin/internal/database_admin_logging_decorator.cc b/google/cloud/spanner/admin/internal/database_admin_logging_decorator.cc index b7c63efa5fd03..1986e655ba841 100644 --- a/google/cloud/spanner/admin/internal/database_admin_logging_decorator.cc +++ b/google/cloud/spanner/admin/internal/database_admin_logging_decorator.cc @@ -482,6 +482,51 @@ DatabaseAdminLogging::ListBackupSchedules( context, options, request, __func__, tracing_options_); } +StatusOr +DatabaseAdminLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DatabaseAdminLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DatabaseAdminLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DatabaseAdminLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> DatabaseAdminLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/spanner/admin/internal/database_admin_logging_decorator.h b/google/cloud/spanner/admin/internal/database_admin_logging_decorator.h index d0e8e19c8902d..be5a56f71b47d 100644 --- a/google/cloud/spanner/admin/internal/database_admin_logging_decorator.h +++ b/google/cloud/spanner/admin/internal/database_admin_logging_decorator.h @@ -212,6 +212,22 @@ class DatabaseAdminLogging : public DatabaseAdminStub { google::spanner::admin::database::v1::ListBackupSchedulesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/spanner/admin/internal/database_admin_metadata_decorator.cc b/google/cloud/spanner/admin/internal/database_admin_metadata_decorator.cc index d7b8c44bd48b7..74e0ddf70ba5e 100644 --- a/google/cloud/spanner/admin/internal/database_admin_metadata_decorator.cc +++ b/google/cloud/spanner/admin/internal/database_admin_metadata_decorator.cc @@ -360,6 +360,39 @@ DatabaseAdminMetadata::ListBackupSchedules( return child_->ListBackupSchedules(context, options, request); } +StatusOr +DatabaseAdminMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr DatabaseAdminMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status DatabaseAdminMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status DatabaseAdminMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + future> DatabaseAdminMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/spanner/admin/internal/database_admin_metadata_decorator.h b/google/cloud/spanner/admin/internal/database_admin_metadata_decorator.h index d003fe21af1bb..c425a8617abc4 100644 --- a/google/cloud/spanner/admin/internal/database_admin_metadata_decorator.h +++ b/google/cloud/spanner/admin/internal/database_admin_metadata_decorator.h @@ -212,6 +212,22 @@ class DatabaseAdminMetadata : public DatabaseAdminStub { google::spanner::admin::database::v1::ListBackupSchedulesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/spanner/admin/internal/database_admin_rest_connection_impl.cc b/google/cloud/spanner/admin/internal/database_admin_rest_connection_impl.cc index 73d0987c99791..5ff0be506ca87 100644 --- a/google/cloud/spanner/admin/internal/database_admin_rest_connection_impl.cc +++ b/google/cloud/spanner/admin/internal/database_admin_rest_connection_impl.cc @@ -1009,6 +1009,80 @@ DatabaseAdminRestConnectionImpl::ListBackupSchedules( }); } +StreamRange +DatabaseAdminRestConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::rest_internal::RestRetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(rest_context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DatabaseAdminRestConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::rest_internal::RestRetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(rest_context, options, request); + }, + *current, request, __func__); +} + +Status DatabaseAdminRestConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::rest_internal::RestRetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(rest_context, options, request); + }, + *current, request, __func__); +} + +Status DatabaseAdminRestConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::rest_internal::RestRetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(rest_context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner_admin_internal } // namespace cloud diff --git a/google/cloud/spanner/admin/internal/database_admin_rest_connection_impl.h b/google/cloud/spanner/admin/internal/database_admin_rest_connection_impl.h index f7de0d3670e24..6fb7cc8363262 100644 --- a/google/cloud/spanner/admin/internal/database_admin_rest_connection_impl.h +++ b/google/cloud/spanner/admin/internal/database_admin_rest_connection_impl.h @@ -207,6 +207,18 @@ class DatabaseAdminRestConnectionImpl google::spanner::admin::database::v1::ListBackupSchedulesRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: static std::unique_ptr retry_policy( Options const& options) { diff --git a/google/cloud/spanner/admin/internal/database_admin_rest_logging_decorator.cc b/google/cloud/spanner/admin/internal/database_admin_rest_logging_decorator.cc index e76d8017da64f..2398a34ddf0be 100644 --- a/google/cloud/spanner/admin/internal/database_admin_rest_logging_decorator.cc +++ b/google/cloud/spanner/admin/internal/database_admin_rest_logging_decorator.cc @@ -484,6 +484,51 @@ DatabaseAdminRestLogging::ListBackupSchedules( rest_context, options, request, __func__, tracing_options_); } +StatusOr +DatabaseAdminRestLogging::ListOperations( + rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(rest_context, options, request); + }, + rest_context, options, request, __func__, tracing_options_); +} + +StatusOr DatabaseAdminRestLogging::GetOperation( + rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(rest_context, options, request); + }, + rest_context, options, request, __func__, tracing_options_); +} + +Status DatabaseAdminRestLogging::DeleteOperation( + rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(rest_context, options, request); + }, + rest_context, options, request, __func__, tracing_options_); +} + +Status DatabaseAdminRestLogging::CancelOperation( + rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(rest_context, options, request); + }, + rest_context, options, request, __func__, tracing_options_); +} + future> DatabaseAdminRestLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/spanner/admin/internal/database_admin_rest_logging_decorator.h b/google/cloud/spanner/admin/internal/database_admin_rest_logging_decorator.h index 4d15486ced9dc..282c2a39356ae 100644 --- a/google/cloud/spanner/admin/internal/database_admin_rest_logging_decorator.h +++ b/google/cloud/spanner/admin/internal/database_admin_rest_logging_decorator.h @@ -240,6 +240,26 @@ class DatabaseAdminRestLogging : public DatabaseAdminRestStub { google::spanner::admin::database::v1::ListBackupSchedulesRequest const& request) override; + StatusOr ListOperations( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::unique_ptr rest_context, diff --git a/google/cloud/spanner/admin/internal/database_admin_rest_metadata_decorator.cc b/google/cloud/spanner/admin/internal/database_admin_rest_metadata_decorator.cc index e02ac6ecd2d2b..7f6220e6ebe28 100644 --- a/google/cloud/spanner/admin/internal/database_admin_rest_metadata_decorator.cc +++ b/google/cloud/spanner/admin/internal/database_admin_rest_metadata_decorator.cc @@ -315,6 +315,36 @@ DatabaseAdminRestMetadata::ListBackupSchedules( return child_->ListBackupSchedules(rest_context, options, request); } +StatusOr +DatabaseAdminRestMetadata::ListOperations( + rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(rest_context, options); + return child_->ListOperations(rest_context, options, request); +} + +StatusOr +DatabaseAdminRestMetadata::GetOperation( + rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(rest_context, options); + return child_->GetOperation(rest_context, options, request); +} + +Status DatabaseAdminRestMetadata::DeleteOperation( + rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(rest_context, options); + return child_->DeleteOperation(rest_context, options, request); +} + +Status DatabaseAdminRestMetadata::CancelOperation( + rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(rest_context, options); + return child_->CancelOperation(rest_context, options, request); +} + future> DatabaseAdminRestMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/spanner/admin/internal/database_admin_rest_metadata_decorator.h b/google/cloud/spanner/admin/internal/database_admin_rest_metadata_decorator.h index 14b4dde31c736..6008422ada21a 100644 --- a/google/cloud/spanner/admin/internal/database_admin_rest_metadata_decorator.h +++ b/google/cloud/spanner/admin/internal/database_admin_rest_metadata_decorator.h @@ -244,6 +244,26 @@ class DatabaseAdminRestMetadata : public DatabaseAdminRestStub { google::spanner::admin::database::v1::ListBackupSchedulesRequest const& request) override; + StatusOr ListOperations( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + google::cloud::future> AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/spanner/admin/internal/database_admin_rest_stub.cc b/google/cloud/spanner/admin/internal/database_admin_rest_stub.cc index 5ced75e24d78c..0a90c4627b183 100644 --- a/google/cloud/spanner/admin/internal/database_admin_rest_stub.cc +++ b/google/cloud/spanner/admin/internal/database_admin_rest_stub.cc @@ -602,6 +602,61 @@ DefaultDatabaseAdminRestStub::ListBackupSchedules( std::move(query_params)); } +StatusOr +DefaultDatabaseAdminRestStub::ListOperations( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::ListOperationsRequest const& request) { + std::vector> query_params; + query_params.push_back({"filter", request.filter()}); + query_params.push_back({"page_size", std::to_string(request.page_size())}); + query_params.push_back({"page_token", request.page_token()}); + query_params = + rest_internal::TrimEmptyQueryParameters(std::move(query_params)); + return rest_internal::Get( + *service_, rest_context, request, false, + absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", + request.name()), + std::move(query_params)); +} + +StatusOr +DefaultDatabaseAdminRestStub::GetOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::GetOperationRequest const& request) { + std::vector> query_params; + return rest_internal::Get( + *service_, rest_context, request, false, + absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", + request.name()), + std::move(query_params)); +} + +Status DefaultDatabaseAdminRestStub::DeleteOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + std::vector> query_params; + return rest_internal::Delete( + *service_, rest_context, request, false, + absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", + request.name()), + std::move(query_params)); +} + +Status DefaultDatabaseAdminRestStub::CancelOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::CancelOperationRequest const& request) { + std::vector> query_params; + return rest_internal::Post( + *service_, rest_context, request, false, + absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", + request.name(), ":cancel"), + std::move(query_params)); +} + future> DefaultDatabaseAdminRestStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/spanner/admin/internal/database_admin_rest_stub.h b/google/cloud/spanner/admin/internal/database_admin_rest_stub.h index 43485532f984a..9f1021bc567b3 100644 --- a/google/cloud/spanner/admin/internal/database_admin_rest_stub.h +++ b/google/cloud/spanner/admin/internal/database_admin_rest_stub.h @@ -241,6 +241,26 @@ class DatabaseAdminRestStub { google::spanner::admin::database::v1::ListBackupSchedulesRequest const& request) = 0; + virtual StatusOr ListOperations( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::unique_ptr rest_context, @@ -461,6 +481,26 @@ class DefaultDatabaseAdminRestStub : public DatabaseAdminRestStub { google::spanner::admin::database::v1::ListBackupSchedulesRequest const& request) override; + StatusOr ListOperations( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::unique_ptr rest_context, diff --git a/google/cloud/spanner/admin/internal/database_admin_stub.cc b/google/cloud/spanner/admin/internal/database_admin_stub.cc index 2ecb1f7377e12..85f84bb5007be 100644 --- a/google/cloud/spanner/admin/internal/database_admin_stub.cc +++ b/google/cloud/spanner/admin/internal/database_admin_stub.cc @@ -457,6 +457,51 @@ DefaultDatabaseAdminStub::ListBackupSchedules( return response; } +StatusOr +DefaultDatabaseAdminStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultDatabaseAdminStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultDatabaseAdminStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultDatabaseAdminStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + future> DefaultDatabaseAdminStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/spanner/admin/internal/database_admin_stub.h b/google/cloud/spanner/admin/internal/database_admin_stub.h index 113b736ded73f..320050e34e3ab 100644 --- a/google/cloud/spanner/admin/internal/database_admin_stub.h +++ b/google/cloud/spanner/admin/internal/database_admin_stub.h @@ -217,6 +217,22 @@ class DatabaseAdminStub { google::spanner::admin::database::v1::ListBackupSchedulesRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -236,9 +252,13 @@ class DefaultDatabaseAdminStub : public DatabaseAdminStub { std::unique_ptr< google::spanner::admin::database::v1::DatabaseAdmin::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr ListDatabases( @@ -413,6 +433,22 @@ class DefaultDatabaseAdminStub : public DatabaseAdminStub { google::spanner::admin::database::v1::ListBackupSchedulesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -429,6 +465,8 @@ class DefaultDatabaseAdminStub : public DatabaseAdminStub { std::unique_ptr< google::spanner::admin::database::v1::DatabaseAdmin::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/spanner/admin/internal/database_admin_stub_factory.cc b/google/cloud/spanner/admin/internal/database_admin_stub_factory.cc index be5e7cd46e998..326f6eb10b895 100644 --- a/google/cloud/spanner/admin/internal/database_admin_stub_factory.cc +++ b/google/cloud/spanner/admin/internal/database_admin_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 CreateDefaultDatabaseAdminStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::spanner::admin::database::v1::DatabaseAdmin::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/spanner/admin/internal/database_admin_tracing_connection.cc b/google/cloud/spanner/admin/internal/database_admin_tracing_connection.cc index 40f2d6524e4c0..cd659dfb4ed4d 100644 --- a/google/cloud/spanner/admin/internal/database_admin_tracing_connection.cc +++ b/google/cloud/spanner/admin/internal/database_admin_tracing_connection.cc @@ -404,6 +404,42 @@ DatabaseAdminTracingConnection::ListBackupSchedules( std::move(sr)); } +StreamRange +DatabaseAdminTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "spanner_admin::DatabaseAdminConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DatabaseAdminTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "spanner_admin::DatabaseAdminConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status DatabaseAdminTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "spanner_admin::DatabaseAdminConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status DatabaseAdminTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "spanner_admin::DatabaseAdminConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/spanner/admin/internal/database_admin_tracing_connection.h b/google/cloud/spanner/admin/internal/database_admin_tracing_connection.h index de2426a2c0c11..db4cb24c9266d 100644 --- a/google/cloud/spanner/admin/internal/database_admin_tracing_connection.h +++ b/google/cloud/spanner/admin/internal/database_admin_tracing_connection.h @@ -197,6 +197,18 @@ class DatabaseAdminTracingConnection google::spanner::admin::database::v1::ListBackupSchedulesRequest request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/spanner/admin/internal/database_admin_tracing_stub.cc b/google/cloud/spanner/admin/internal/database_admin_tracing_stub.cc index 029f428efa8e4..bebcf7991f64e 100644 --- a/google/cloud/spanner/admin/internal/database_admin_tracing_stub.cc +++ b/google/cloud/spanner/admin/internal/database_admin_tracing_stub.cc @@ -432,6 +432,51 @@ DatabaseAdminTracingStub::ListBackupSchedules( context, *span, child_->ListBackupSchedules(context, options, request)); } +StatusOr +DatabaseAdminTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.spanner.admin.database.v1.DatabaseAdmin", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr DatabaseAdminTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.spanner.admin.database.v1.DatabaseAdmin", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status DatabaseAdminTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.spanner.admin.database.v1.DatabaseAdmin", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status DatabaseAdminTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.spanner.admin.database.v1.DatabaseAdmin", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + future> DatabaseAdminTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/spanner/admin/internal/database_admin_tracing_stub.h b/google/cloud/spanner/admin/internal/database_admin_tracing_stub.h index fa9a40c0ffbc9..24f6884029136 100644 --- a/google/cloud/spanner/admin/internal/database_admin_tracing_stub.h +++ b/google/cloud/spanner/admin/internal/database_admin_tracing_stub.h @@ -211,6 +211,22 @@ class DatabaseAdminTracingStub : public DatabaseAdminStub { google::spanner::admin::database::v1::ListBackupSchedulesRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/spanner/admin/mocks/mock_database_admin_connection.h b/google/cloud/spanner/admin/mocks/mock_database_admin_connection.h index 5edfef31aeeba..f56d3242f74a2 100644 --- a/google/cloud/spanner/admin/mocks/mock_database_admin_connection.h +++ b/google/cloud/spanner/admin/mocks/mock_database_admin_connection.h @@ -400,6 +400,21 @@ class MockDatabaseAdminConnection (google::spanner::admin::database::v1::ListBackupSchedulesRequest request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END 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/v1/adaptation_client.cc b/google/cloud/speech/v1/adaptation_client.cc index eb0be67973a8a..118ae9eaf874b 100644 --- a/google/cloud/speech/v1/adaptation_client.cc +++ b/google/cloud/speech/v1/adaptation_client.cc @@ -203,6 +203,35 @@ Status AdaptationClient::DeleteCustomClass( return connection_->DeleteCustomClass(request); } +StreamRange AdaptationClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange AdaptationClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr AdaptationClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr AdaptationClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace speech_v1 } // namespace cloud diff --git a/google/cloud/speech/v1/adaptation_client.h b/google/cloud/speech/v1/adaptation_client.h index d426f6604360c..237806d41b505 100644 --- a/google/cloud/speech/v1/adaptation_client.h +++ b/google/cloud/speech/v1/adaptation_client.h @@ -765,6 +765,158 @@ class AdaptationClient { google::cloud::speech::v1::DeleteCustomClassRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/speech/v1/adaptation_connection.cc b/google/cloud/speech/v1/adaptation_connection.cc index 29812467411a3..585a9ae291810 100644 --- a/google/cloud/speech/v1/adaptation_connection.cc +++ b/google/cloud/speech/v1/adaptation_connection.cc @@ -100,6 +100,19 @@ Status AdaptationConnection::DeleteCustomClass( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +AdaptationConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr AdaptationConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeAdaptationConnection( Options options) { internal::CheckExpectedOptions ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/speech/v1/adaptation_connection_idempotency_policy.cc b/google/cloud/speech/v1/adaptation_connection_idempotency_policy.cc index 54a61f9e057d4..cae1adb05fd48 100644 --- a/google/cloud/speech/v1/adaptation_connection_idempotency_policy.cc +++ b/google/cloud/speech/v1/adaptation_connection_idempotency_policy.cc @@ -84,6 +84,16 @@ Idempotency AdaptationConnectionIdempotencyPolicy::DeleteCustomClass( return Idempotency::kNonIdempotent; } +Idempotency AdaptationConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AdaptationConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultAdaptationConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/speech/v1/adaptation_connection_idempotency_policy.h b/google/cloud/speech/v1/adaptation_connection_idempotency_policy.h index c40a5c37feb97..d9eb54dd36a7e 100644 --- a/google/cloud/speech/v1/adaptation_connection_idempotency_policy.h +++ b/google/cloud/speech/v1/adaptation_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -65,6 +66,12 @@ class AdaptationConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteCustomClass( google::cloud::speech::v1::DeleteCustomClassRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/speech/v1/internal/adaptation_auth_decorator.cc b/google/cloud/speech/v1/internal/adaptation_auth_decorator.cc index 4795c812b574d..200f07d57167b 100644 --- a/google/cloud/speech/v1/internal/adaptation_auth_decorator.cc +++ b/google/cloud/speech/v1/internal/adaptation_auth_decorator.cc @@ -115,6 +115,23 @@ Status AdaptationAuth::DeleteCustomClass( return child_->DeleteCustomClass(context, options, request); } +StatusOr +AdaptationAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr AdaptationAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace speech_v1_internal } // namespace cloud diff --git a/google/cloud/speech/v1/internal/adaptation_auth_decorator.h b/google/cloud/speech/v1/internal/adaptation_auth_decorator.h index 2aaf09201ffe0..325d4dfef53c8 100644 --- a/google/cloud/speech/v1/internal/adaptation_auth_decorator.h +++ b/google/cloud/speech/v1/internal/adaptation_auth_decorator.h @@ -85,6 +85,14 @@ class AdaptationAuth : public AdaptationStub { google::cloud::speech::v1::DeleteCustomClassRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/speech/v1/internal/adaptation_connection_impl.cc b/google/cloud/speech/v1/internal/adaptation_connection_impl.cc index dcbee03fa4701..34e003611e8c5 100644 --- a/google/cloud/speech/v1/internal/adaptation_connection_impl.cc +++ b/google/cloud/speech/v1/internal/adaptation_connection_impl.cc @@ -238,6 +238,52 @@ Status AdaptationConnectionImpl::DeleteCustomClass( *current, request, __func__); } +StreamRange +AdaptationConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr AdaptationConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace speech_v1_internal } // namespace cloud diff --git a/google/cloud/speech/v1/internal/adaptation_connection_impl.h b/google/cloud/speech/v1/internal/adaptation_connection_impl.h index c5219607002bd..dee4eaf2779de 100644 --- a/google/cloud/speech/v1/internal/adaptation_connection_impl.h +++ b/google/cloud/speech/v1/internal/adaptation_connection_impl.h @@ -84,6 +84,12 @@ class AdaptationConnectionImpl : public speech_v1::AdaptationConnection { google::cloud::speech::v1::DeleteCustomClassRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/speech/v1/internal/adaptation_logging_decorator.cc b/google/cloud/speech/v1/internal/adaptation_logging_decorator.cc index 4f319189064d1..a84b5d529af17 100644 --- a/google/cloud/speech/v1/internal/adaptation_logging_decorator.cc +++ b/google/cloud/speech/v1/internal/adaptation_logging_decorator.cc @@ -156,6 +156,29 @@ Status AdaptationLogging::DeleteCustomClass( context, options, request, __func__, tracing_options_); } +StatusOr +AdaptationLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AdaptationLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace speech_v1_internal } // namespace cloud diff --git a/google/cloud/speech/v1/internal/adaptation_logging_decorator.h b/google/cloud/speech/v1/internal/adaptation_logging_decorator.h index b509801f125be..872ee8a445b1a 100644 --- a/google/cloud/speech/v1/internal/adaptation_logging_decorator.h +++ b/google/cloud/speech/v1/internal/adaptation_logging_decorator.h @@ -85,6 +85,14 @@ class AdaptationLogging : public AdaptationStub { google::cloud::speech::v1::DeleteCustomClassRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/speech/v1/internal/adaptation_metadata_decorator.cc b/google/cloud/speech/v1/internal/adaptation_metadata_decorator.cc index 8d5f6ba907255..312dd4892dd78 100644 --- a/google/cloud/speech/v1/internal/adaptation_metadata_decorator.cc +++ b/google/cloud/speech/v1/internal/adaptation_metadata_decorator.cc @@ -133,6 +133,22 @@ Status AdaptationMetadata::DeleteCustomClass( return child_->DeleteCustomClass(context, options, request); } +StatusOr +AdaptationMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, absl::StrCat()); + return child_->ListOperations(context, options, request); +} + +StatusOr AdaptationMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + void AdaptationMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/speech/v1/internal/adaptation_metadata_decorator.h b/google/cloud/speech/v1/internal/adaptation_metadata_decorator.h index 1ec9423d1a627..b4fd52ac1e2a4 100644 --- a/google/cloud/speech/v1/internal/adaptation_metadata_decorator.h +++ b/google/cloud/speech/v1/internal/adaptation_metadata_decorator.h @@ -85,6 +85,14 @@ class AdaptationMetadata : public AdaptationStub { google::cloud::speech::v1::DeleteCustomClassRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/speech/v1/internal/adaptation_stub.cc b/google/cloud/speech/v1/internal/adaptation_stub.cc index aa4924f9942f3..d344e21695ea1 100644 --- a/google/cloud/speech/v1/internal/adaptation_stub.cc +++ b/google/cloud/speech/v1/internal/adaptation_stub.cc @@ -148,6 +148,29 @@ Status DefaultAdaptationStub::DeleteCustomClass( return google::cloud::Status(); } +StatusOr +DefaultAdaptationStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAdaptationStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace speech_v1_internal } // namespace cloud diff --git a/google/cloud/speech/v1/internal/adaptation_stub.h b/google/cloud/speech/v1/internal/adaptation_stub.h index cc2a112ead3bd..d3958e3be9163 100644 --- a/google/cloud/speech/v1/internal/adaptation_stub.h +++ b/google/cloud/speech/v1/internal/adaptation_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -76,14 +77,25 @@ class AdaptationStub { virtual Status DeleteCustomClass( grpc::ClientContext& context, Options const& options, google::cloud::speech::v1::DeleteCustomClassRequest const& request) = 0; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; }; class DefaultAdaptationStub : public AdaptationStub { public: explicit DefaultAdaptationStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr CreatePhraseSet( grpc::ClientContext& context, Options const& options, @@ -132,9 +144,19 @@ class DefaultAdaptationStub : public AdaptationStub { google::cloud::speech::v1::DeleteCustomClassRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/speech/v1/internal/adaptation_stub_factory.cc b/google/cloud/speech/v1/internal/adaptation_stub_factory.cc index cea0f12d01030..79612b3e89d64 100644 --- a/google/cloud/speech/v1/internal/adaptation_stub_factory.cc +++ b/google/cloud/speech/v1/internal/adaptation_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 CreateDefaultAdaptationStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::speech::v1::Adaptation::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), std::move(stub)); diff --git a/google/cloud/speech/v1/internal/adaptation_tracing_connection.cc b/google/cloud/speech/v1/internal/adaptation_tracing_connection.cc index 8c01f7342bd84..c257af21efe52 100644 --- a/google/cloud/speech/v1/internal/adaptation_tracing_connection.cc +++ b/google/cloud/speech/v1/internal/adaptation_tracing_connection.cc @@ -125,6 +125,26 @@ Status AdaptationTracingConnection::DeleteCustomClass( return internal::EndSpan(*span, child_->DeleteCustomClass(request)); } +StreamRange +AdaptationTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("speech_v1::AdaptationConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AdaptationTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("speech_v1::AdaptationConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/speech/v1/internal/adaptation_tracing_connection.h b/google/cloud/speech/v1/internal/adaptation_tracing_connection.h index 6c87d26beb7a1..8a9fe20d67bc5 100644 --- a/google/cloud/speech/v1/internal/adaptation_tracing_connection.h +++ b/google/cloud/speech/v1/internal/adaptation_tracing_connection.h @@ -75,6 +75,12 @@ class AdaptationTracingConnection : public speech_v1::AdaptationConnection { google::cloud::speech::v1::DeleteCustomClassRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/speech/v1/internal/adaptation_tracing_stub.cc b/google/cloud/speech/v1/internal/adaptation_tracing_stub.cc index 460ea7a97e072..b215d4dfa5ba4 100644 --- a/google/cloud/speech/v1/internal/adaptation_tracing_stub.cc +++ b/google/cloud/speech/v1/internal/adaptation_tracing_stub.cc @@ -150,6 +150,29 @@ Status AdaptationTracingStub::DeleteCustomClass( context, *span, child_->DeleteCustomClass(context, options, request)); } +StatusOr +AdaptationTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.speech.v1.Adaptation", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr AdaptationTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.speech.v1.Adaptation", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeAdaptationTracingStub( diff --git a/google/cloud/speech/v1/internal/adaptation_tracing_stub.h b/google/cloud/speech/v1/internal/adaptation_tracing_stub.h index 68d0b6dd0283a..c90f7b696b072 100644 --- a/google/cloud/speech/v1/internal/adaptation_tracing_stub.h +++ b/google/cloud/speech/v1/internal/adaptation_tracing_stub.h @@ -85,6 +85,14 @@ class AdaptationTracingStub : public AdaptationStub { google::cloud::speech::v1::DeleteCustomClassRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/speech/v1/internal/speech_auth_decorator.cc b/google/cloud/speech/v1/internal/speech_auth_decorator.cc index 85ff42f932ed1..757ce0eefb590 100644 --- a/google/cloud/speech/v1/internal/speech_auth_decorator.cc +++ b/google/cloud/speech/v1/internal/speech_auth_decorator.cc @@ -87,6 +87,23 @@ SpeechAuth::AsyncStreamingRecognize( std::move(context), auth_, StreamAuth::StreamFactory(std::move(call))); } +StatusOr +SpeechAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr SpeechAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + future> SpeechAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/speech/v1/internal/speech_auth_decorator.h b/google/cloud/speech/v1/internal/speech_auth_decorator.h index df3451e96c98c..6cbdf1ee3f2ce 100644 --- a/google/cloud/speech/v1/internal/speech_auth_decorator.h +++ b/google/cloud/speech/v1/internal/speech_auth_decorator.h @@ -63,6 +63,14 @@ class SpeechAuth : public SpeechStub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/speech/v1/internal/speech_connection_impl.cc b/google/cloud/speech/v1/internal/speech_connection_impl.cc index 2aa7552dcd468..cac18152fb228 100644 --- a/google/cloud/speech/v1/internal/speech_connection_impl.cc +++ b/google/cloud/speech/v1/internal/speech_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 @@ -178,6 +179,52 @@ SpeechConnectionImpl::AsyncStreamingRecognize() { internal::SaveCurrentOptions()); } +StreamRange +SpeechConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr SpeechConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace speech_v1_internal } // namespace cloud diff --git a/google/cloud/speech/v1/internal/speech_connection_impl.h b/google/cloud/speech/v1/internal/speech_connection_impl.h index d49d866f9856d..471dc894e89eb 100644 --- a/google/cloud/speech/v1/internal/speech_connection_impl.h +++ b/google/cloud/speech/v1/internal/speech_connection_impl.h @@ -31,6 +31,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 @@ -72,6 +73,12 @@ class SpeechConnectionImpl : public speech_v1::SpeechConnection { google::cloud::speech::v1::StreamingRecognizeResponse>> AsyncStreamingRecognize() override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/speech/v1/internal/speech_logging_decorator.cc b/google/cloud/speech/v1/internal/speech_logging_decorator.cc index 5cda0754d6a9d..98066d2c2aa89 100644 --- a/google/cloud/speech/v1/internal/speech_logging_decorator.cc +++ b/google/cloud/speech/v1/internal/speech_logging_decorator.cc @@ -103,6 +103,29 @@ SpeechLogging::AsyncStreamingRecognize( return stream; } +StatusOr +SpeechLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr SpeechLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> SpeechLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/speech/v1/internal/speech_logging_decorator.h b/google/cloud/speech/v1/internal/speech_logging_decorator.h index 99a36b6c5ba72..5bcb5e9c441ae 100644 --- a/google/cloud/speech/v1/internal/speech_logging_decorator.h +++ b/google/cloud/speech/v1/internal/speech_logging_decorator.h @@ -63,6 +63,14 @@ class SpeechLogging : public SpeechStub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/speech/v1/internal/speech_metadata_decorator.cc b/google/cloud/speech/v1/internal/speech_metadata_decorator.cc index 3d589a61525f4..2663bc75c9c76 100644 --- a/google/cloud/speech/v1/internal/speech_metadata_decorator.cc +++ b/google/cloud/speech/v1/internal/speech_metadata_decorator.cc @@ -82,6 +82,22 @@ SpeechMetadata::AsyncStreamingRecognize( std::move(options)); } +StatusOr +SpeechMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, absl::StrCat()); + return child_->ListOperations(context, options, request); +} + +StatusOr SpeechMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + future> SpeechMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/speech/v1/internal/speech_metadata_decorator.h b/google/cloud/speech/v1/internal/speech_metadata_decorator.h index 77862b2b2fa12..4d0e90d1fded6 100644 --- a/google/cloud/speech/v1/internal/speech_metadata_decorator.h +++ b/google/cloud/speech/v1/internal/speech_metadata_decorator.h @@ -63,6 +63,14 @@ class SpeechMetadata : public SpeechStub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/speech/v1/internal/speech_stub.cc b/google/cloud/speech/v1/internal/speech_stub.cc index 400fd98d3b39c..40218130d66f7 100644 --- a/google/cloud/speech/v1/internal/speech_stub.cc +++ b/google/cloud/speech/v1/internal/speech_stub.cc @@ -91,6 +91,29 @@ DefaultSpeechStub::AsyncStreamingRecognize( }); } +StatusOr +DefaultSpeechStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultSpeechStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&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/v1/internal/speech_stub.h b/google/cloud/speech/v1/internal/speech_stub.h index c135abdc7c3b7..5a0e88ebbd7a5 100644 --- a/google/cloud/speech/v1/internal/speech_stub.h +++ b/google/cloud/speech/v1/internal/speech_stub.h @@ -64,6 +64,14 @@ class SpeechStub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -82,9 +90,13 @@ class DefaultSpeechStub : public SpeechStub { DefaultSpeechStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr Recognize( grpc::ClientContext& context, Options const& options, @@ -110,6 +122,14 @@ class DefaultSpeechStub : public SpeechStub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -124,6 +144,8 @@ class DefaultSpeechStub : public SpeechStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/speech/v1/internal/speech_stub_factory.cc b/google/cloud/speech/v1/internal/speech_stub_factory.cc index d025597105341..40c5da8b021ad 100644 --- a/google/cloud/speech/v1/internal/speech_stub_factory.cc +++ b/google/cloud/speech/v1/internal/speech_stub_factory.cc @@ -29,6 +29,7 @@ #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::v1::Speech::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/speech/v1/internal/speech_tracing_connection.cc b/google/cloud/speech/v1/internal/speech_tracing_connection.cc index 5794db1800127..4d680eadd758c 100644 --- a/google/cloud/speech/v1/internal/speech_tracing_connection.cc +++ b/google/cloud/speech/v1/internal/speech_tracing_connection.cc @@ -18,6 +18,7 @@ #include "google/cloud/speech/v1/internal/speech_tracing_connection.h" #include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" #include #include @@ -78,6 +79,23 @@ SpeechTracingConnection::AsyncStreamingRecognize() { return child_->AsyncStreamingRecognize(); } +StreamRange +SpeechTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan("speech_v1::SpeechConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr SpeechTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan("speech_v1::SpeechConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeSpeechTracingConnection( diff --git a/google/cloud/speech/v1/internal/speech_tracing_connection.h b/google/cloud/speech/v1/internal/speech_tracing_connection.h index 128a895f2b327..705d74ddccfac 100644 --- a/google/cloud/speech/v1/internal/speech_tracing_connection.h +++ b/google/cloud/speech/v1/internal/speech_tracing_connection.h @@ -61,6 +61,12 @@ class SpeechTracingConnection : public speech_v1::SpeechConnection { google::cloud::speech::v1::StreamingRecognizeResponse>> AsyncStreamingRecognize() override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/speech/v1/internal/speech_tracing_stub.cc b/google/cloud/speech/v1/internal/speech_tracing_stub.cc index eb8c8915bad82..a204626591229 100644 --- a/google/cloud/speech/v1/internal/speech_tracing_stub.cc +++ b/google/cloud/speech/v1/internal/speech_tracing_stub.cc @@ -89,6 +89,29 @@ SpeechTracingStub::AsyncStreamingRecognize( std::move(context), std::move(stream), std::move(span)); } +StatusOr +SpeechTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.speech.v1.Speech", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr SpeechTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.speech.v1.Speech", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + future> SpeechTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/speech/v1/internal/speech_tracing_stub.h b/google/cloud/speech/v1/internal/speech_tracing_stub.h index 8a545640c634f..32ebbf32b9335 100644 --- a/google/cloud/speech/v1/internal/speech_tracing_stub.h +++ b/google/cloud/speech/v1/internal/speech_tracing_stub.h @@ -62,6 +62,14 @@ class SpeechTracingStub : public SpeechStub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/speech/v1/mocks/mock_adaptation_connection.h b/google/cloud/speech/v1/mocks/mock_adaptation_connection.h index 32644e8d6c08c..0c301431350fb 100644 --- a/google/cloud/speech/v1/mocks/mock_adaptation_connection.h +++ b/google/cloud/speech/v1/mocks/mock_adaptation_connection.h @@ -93,6 +93,13 @@ class MockAdaptationConnection : public speech_v1::AdaptationConnection { Status, DeleteCustomClass, (google::cloud::speech::v1::DeleteCustomClassRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/speech/v1/mocks/mock_speech_connection.h b/google/cloud/speech/v1/mocks/mock_speech_connection.h index 4cdc15d253e63..032c2e240738c 100644 --- a/google/cloud/speech/v1/mocks/mock_speech_connection.h +++ b/google/cloud/speech/v1/mocks/mock_speech_connection.h @@ -94,6 +94,13 @@ class MockSpeechConnection : public speech_v1::SpeechConnection { google::cloud::speech::v1::StreamingRecognizeRequest, google::cloud::speech::v1::StreamingRecognizeResponse>>), AsyncStreamingRecognize, (), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/speech/v1/speech_client.cc b/google/cloud/speech/v1/speech_client.cc index b521c2701e414..58119b6ff756f 100644 --- a/google/cloud/speech/v1/speech_client.cc +++ b/google/cloud/speech/v1/speech_client.cc @@ -100,6 +100,35 @@ SpeechClient::AsyncStreamingRecognize(Options opts) { return connection_->AsyncStreamingRecognize(); } +StreamRange SpeechClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange SpeechClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr SpeechClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr SpeechClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace speech_v1 } // namespace cloud diff --git a/google/cloud/speech/v1/speech_client.h b/google/cloud/speech/v1/speech_client.h index 1fc785b893311..10f1272c0732a 100644 --- a/google/cloud/speech/v1/speech_client.h +++ b/google/cloud/speech/v1/speech_client.h @@ -309,6 +309,158 @@ class SpeechClient { google::cloud::speech::v1::StreamingRecognizeResponse>> AsyncStreamingRecognize(Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/speech/v1/speech_connection.cc b/google/cloud/speech/v1/speech_connection.cc index 5fa86c83f5d79..abc563f3fd195 100644 --- a/google/cloud/speech/v1/speech_connection.cc +++ b/google/cloud/speech/v1/speech_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 @@ -75,6 +76,18 @@ SpeechConnection::AsyncStreamingRecognize() { Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange SpeechConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr SpeechConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSpeechConnection(Options options) { internal::CheckExpectedOptions #include @@ -202,6 +203,12 @@ class SpeechConnection { google::cloud::speech::v1::StreamingRecognizeRequest, google::cloud::speech::v1::StreamingRecognizeResponse>> AsyncStreamingRecognize(); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/speech/v1/speech_connection_idempotency_policy.cc b/google/cloud/speech/v1/speech_connection_idempotency_policy.cc index f12c2b7d7dbd2..e78b174515189 100644 --- a/google/cloud/speech/v1/speech_connection_idempotency_policy.cc +++ b/google/cloud/speech/v1/speech_connection_idempotency_policy.cc @@ -44,6 +44,16 @@ Idempotency SpeechConnectionIdempotencyPolicy::LongRunningRecognize( return Idempotency::kNonIdempotent; } +Idempotency SpeechConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SpeechConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultSpeechConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/speech/v1/speech_connection_idempotency_policy.h b/google/cloud/speech/v1/speech_connection_idempotency_policy.h index 9ef2f138025a9..470090a8926c9 100644 --- a/google/cloud/speech/v1/speech_connection_idempotency_policy.h +++ b/google/cloud/speech/v1/speech_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 SpeechConnectionIdempotencyPolicy { virtual google::cloud::Idempotency LongRunningRecognize( google::cloud::speech::v1::LongRunningRecognizeRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/speech/v2/internal/speech_auth_decorator.cc b/google/cloud/speech/v2/internal/speech_auth_decorator.cc index 421aa2980370d..2548d0a5fa3f6 100644 --- a/google/cloud/speech/v2/internal/speech_auth_decorator.cc +++ b/google/cloud/speech/v2/internal/speech_auth_decorator.cc @@ -490,6 +490,56 @@ 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); +} + +StatusOr +SpeechAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr SpeechAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status SpeechAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status SpeechAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..b097cbdba1322 100644 --- a/google/cloud/speech/v2/internal/speech_auth_decorator.h +++ b/google/cloud/speech/v2/internal/speech_auth_decorator.h @@ -239,6 +239,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..0b0d9062fa089 100644 --- a/google/cloud/speech/v2/internal/speech_connection_impl.cc +++ b/google/cloud/speech/v2/internal/speech_connection_impl.cc @@ -1429,6 +1429,125 @@ 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__); +} + +StreamRange +SpeechConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr SpeechConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status SpeechConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status SpeechConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..c25fde9d80893 100644 --- a/google/cloud/speech/v2/internal/speech_connection_impl.h +++ b/google/cloud/speech/v2/internal/speech_connection_impl.h @@ -238,6 +238,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..0ef00f263e678 100644 --- a/google/cloud/speech/v2/internal/speech_logging_decorator.cc +++ b/google/cloud/speech/v2/internal/speech_logging_decorator.cc @@ -559,6 +559,74 @@ 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_); +} + +StatusOr +SpeechLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr SpeechLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status SpeechLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status SpeechLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..b5e97c3951d00 100644 --- a/google/cloud/speech/v2/internal/speech_logging_decorator.h +++ b/google/cloud/speech/v2/internal/speech_logging_decorator.h @@ -239,6 +239,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..4c0b2cbd76e80 100644 --- a/google/cloud/speech/v2/internal/speech_metadata_decorator.cc +++ b/google/cloud/speech/v2/internal/speech_metadata_decorator.cc @@ -402,6 +402,56 @@ 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); +} + +StatusOr +SpeechMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr SpeechMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status SpeechMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status SpeechMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..a30d439aa5954 100644 --- a/google/cloud/speech/v2/internal/speech_metadata_decorator.h +++ b/google/cloud/speech/v2/internal/speech_metadata_decorator.h @@ -239,6 +239,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..c90b200a6519e 100644 --- a/google/cloud/speech/v2/internal/speech_stub.cc +++ b/google/cloud/speech/v2/internal/speech_stub.cc @@ -532,6 +532,74 @@ 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; +} + +StatusOr +DefaultSpeechStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultSpeechStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultSpeechStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultSpeechStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..f23c057c017c2 100644 --- a/google/cloud/speech/v2/internal/speech_stub.h +++ b/google/cloud/speech/v2/internal/speech_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 @@ -225,6 +226,31 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -243,9 +269,16 @@ class DefaultSpeechStub : public SpeechStub { DefaultSpeechStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateRecognizer( google::cloud::CompletionQueue& cq, @@ -447,6 +480,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -461,6 +518,10 @@ class DefaultSpeechStub : public SpeechStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..1a9d278fd1b8c 100644 --- a/google/cloud/speech/v2/internal/speech_stub_factory.cc +++ b/google/cloud/speech/v2/internal/speech_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 @@ -43,8 +45,13 @@ 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_operations_stub = + google::longrunning::Operations::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_operations_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..0efaeaa2e73f1 100644 --- a/google/cloud/speech/v2/internal/speech_tracing_connection.cc +++ b/google/cloud/speech/v2/internal/speech_tracing_connection.cc @@ -504,6 +504,57 @@ 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)); +} + +StreamRange +SpeechTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan("speech_v2::SpeechConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr SpeechTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan("speech_v2::SpeechConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status SpeechTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = + internal::MakeSpan("speech_v2::SpeechConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status SpeechTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("speech_v2::SpeechConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..1c2fc7be4f0ed 100644 --- a/google/cloud/speech/v2/internal/speech_tracing_connection.h +++ b/google/cloud/speech/v2/internal/speech_tracing_connection.h @@ -226,6 +226,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..24199bfe37cba 100644 --- a/google/cloud/speech/v2/internal/speech_tracing_stub.cc +++ b/google/cloud/speech/v2/internal/speech_tracing_stub.cc @@ -493,6 +493,74 @@ 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)); +} + +StatusOr +SpeechTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.speech.v2.Speech", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr SpeechTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.speech.v2.Speech", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status SpeechTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.speech.v2.Speech", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status SpeechTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.speech.v2.Speech", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..61b985aa8c805 100644 --- a/google/cloud/speech/v2/internal/speech_tracing_stub.h +++ b/google/cloud/speech/v2/internal/speech_tracing_stub.h @@ -238,6 +238,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..d22771b809f18 100644 --- a/google/cloud/speech/v2/mocks/mock_speech_connection.h +++ b/google/cloud/speech/v2/mocks/mock_speech_connection.h @@ -589,6 +589,29 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..60a709bcace52 100644 --- a/google/cloud/speech/v2/speech_client.cc +++ b/google/cloud/speech/v2/speech_client.cc @@ -745,6 +745,73 @@ 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); +} + +StreamRange SpeechClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange SpeechClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr SpeechClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr SpeechClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status SpeechClient::DeleteOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status SpeechClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status SpeechClient::CancelOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status SpeechClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..be22f48249b91 100644 --- a/google/cloud/speech/v2/speech_client.h +++ b/google/cloud/speech/v2/speech_client.h @@ -2296,6 +2296,356 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..2eb49d1f33800 100644 --- a/google/cloud/speech/v2/speech_connection.cc +++ b/google/cloud/speech/v2/speech_connection.cc @@ -378,6 +378,40 @@ 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"); +} + +StreamRange SpeechConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr SpeechConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status SpeechConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status SpeechConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSpeechConnection( std::string const& location, Options options) { internal::CheckExpectedOptions> UndeletePhraseSet(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..4c04a4d4259dc 100644 --- a/google/cloud/speech/v2/speech_connection_idempotency_policy.cc +++ b/google/cloud/speech/v2/speech_connection_idempotency_policy.cc @@ -144,6 +144,36 @@ 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; +} + +Idempotency SpeechConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SpeechConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency SpeechConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency SpeechConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..61453cf20b41b 100644 --- a/google/cloud/speech/v2/speech_connection_idempotency_policy.h +++ b/google/cloud/speech/v2/speech_connection_idempotency_policy.h @@ -21,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -101,6 +103,24 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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/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..cf0797339b1bf 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,56 @@ 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); +} + +StatusOr +StorageInsightsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr StorageInsightsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status StorageInsightsAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status StorageInsightsAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..c0c4e0e536078 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..5563e5102b552 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,127 @@ 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__); +} + +StreamRange +StorageInsightsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +StorageInsightsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status StorageInsightsConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status StorageInsightsConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..84d7f6c4733d6 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..8e809b7a8b900 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,74 @@ 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_); +} + +StatusOr +StorageInsightsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr StorageInsightsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status StorageInsightsLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status StorageInsightsLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..77268b612e9ad 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..ea215ca85c634 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,57 @@ 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); +} + +StatusOr +StorageInsightsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr StorageInsightsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status StorageInsightsMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status StorageInsightsMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..377483f6c8414 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..002241b6ab81f 100644 --- a/google/cloud/storageinsights/v1/internal/storage_insights_stub.cc +++ b/google/cloud/storageinsights/v1/internal/storage_insights_stub.cc @@ -118,6 +118,76 @@ 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; +} + +StatusOr +DefaultStorageInsightsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultStorageInsightsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultStorageInsightsStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultStorageInsightsStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..5301633fb9b06 100644 --- a/google/cloud/storageinsights/v1/internal/storage_insights_stub.h +++ b/google/cloud/storageinsights/v1/internal/storage_insights_stub.h @@ -22,7 +22,9 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include +#include #include #include @@ -77,6 +79,31 @@ 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; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; }; class DefaultStorageInsightsStub : public StorageInsightsStub { @@ -84,8 +111,14 @@ 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 + operations_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListReportConfigs( @@ -124,10 +157,38 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr< google::cloud::storageinsights::v1::StorageInsights::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..2d5c5d2432704 100644 --- a/google/cloud/storageinsights/v1/internal/storage_insights_stub_factory.cc +++ b/google/cloud/storageinsights/v1/internal/storage_insights_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,14 @@ std::shared_ptr CreateDefaultStorageInsightsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::storageinsights::v1::StorageInsights::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..a4c27072118fc 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,62 @@ 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)); +} + +StreamRange +StorageInsightsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "storageinsights_v1::StorageInsightsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +StorageInsightsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "storageinsights_v1::StorageInsightsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status StorageInsightsTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "storageinsights_v1::StorageInsightsConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status StorageInsightsTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "storageinsights_v1::StorageInsightsConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..3eb20ac1f77fc 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..4b89d16e86c6d 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,76 @@ 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)); +} + +StatusOr +StorageInsightsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.storageinsights.v1.StorageInsights", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +StorageInsightsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.storageinsights.v1.StorageInsights", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status StorageInsightsTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.storageinsights.v1.StorageInsights", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status StorageInsightsTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.storageinsights.v1.StorageInsights", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..f864dfbb05821 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..1940b30a08c41 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,29 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..9f85ced687267 100644 --- a/google/cloud/storageinsights/v1/storage_insights_client.cc +++ b/google/cloud/storageinsights/v1/storage_insights_client.cc @@ -155,6 +155,78 @@ 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); +} + +StreamRange +StorageInsightsClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +StorageInsightsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr StorageInsightsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr StorageInsightsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status StorageInsightsClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status StorageInsightsClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status StorageInsightsClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status StorageInsightsClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..23d5e1a72c9f1 100644 --- a/google/cloud/storageinsights/v1/storage_insights_client.h +++ b/google/cloud/storageinsights/v1/storage_insights_client.h @@ -521,6 +521,356 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..34c6192395b49 100644 --- a/google/cloud/storageinsights/v1/storage_insights_connection.cc +++ b/google/cloud/storageinsights/v1/storage_insights_connection.cc @@ -83,6 +83,44 @@ 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"); +} + +StreamRange +StorageInsightsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +StorageInsightsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status StorageInsightsConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status StorageInsightsConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeStorageInsightsConnection( Options options) { internal::CheckExpectedOptions ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..0e97ea6009598 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,36 @@ 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; +} + +Idempotency StorageInsightsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency StorageInsightsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency StorageInsightsConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency StorageInsightsConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..d7811d3ca62be 100644 --- a/google/cloud/storageinsights/v1/storage_insights_connection_idempotency_policy.h +++ b/google/cloud/storageinsights/v1/storage_insights_connection_idempotency_policy.h @@ -21,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -62,6 +64,24 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/storagetransfer/v1/internal/storage_transfer_auth_decorator.cc b/google/cloud/storagetransfer/v1/internal/storage_transfer_auth_decorator.cc index 13e851f2d5868..d597f1587909f 100644 --- a/google/cloud/storagetransfer/v1/internal/storage_transfer_auth_decorator.cc +++ b/google/cloud/storagetransfer/v1/internal/storage_transfer_auth_decorator.cc @@ -175,6 +175,32 @@ Status StorageTransferServiceAuth::DeleteAgentPool( return child_->DeleteAgentPool(context, options, request); } +StatusOr +StorageTransferServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +StorageTransferServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status StorageTransferServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + future> StorageTransferServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/storagetransfer/v1/internal/storage_transfer_auth_decorator.h b/google/cloud/storagetransfer/v1/internal/storage_transfer_auth_decorator.h index b3851467f0c4a..d6535c655ac91 100644 --- a/google/cloud/storagetransfer/v1/internal/storage_transfer_auth_decorator.h +++ b/google/cloud/storagetransfer/v1/internal/storage_transfer_auth_decorator.h @@ -116,6 +116,18 @@ class StorageTransferServiceAuth : public StorageTransferServiceStub { google::storagetransfer::v1::DeleteAgentPoolRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/storagetransfer/v1/internal/storage_transfer_connection_impl.cc b/google/cloud/storagetransfer/v1/internal/storage_transfer_connection_impl.cc index ae233c1c2994b..e497114632ea0 100644 --- a/google/cloud/storagetransfer/v1/internal/storage_transfer_connection_impl.cc +++ b/google/cloud/storagetransfer/v1/internal/storage_transfer_connection_impl.cc @@ -397,6 +397,67 @@ Status StorageTransferServiceConnectionImpl::DeleteAgentPool( *current, request, __func__); } +StreamRange +StorageTransferServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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< + storagetransfer_v1::StorageTransferServiceRetryPolicy>( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +StorageTransferServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status StorageTransferServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace storagetransfer_v1_internal } // namespace cloud diff --git a/google/cloud/storagetransfer/v1/internal/storage_transfer_connection_impl.h b/google/cloud/storagetransfer/v1/internal/storage_transfer_connection_impl.h index bbdeeade5cf6c..914c3f3771f09 100644 --- a/google/cloud/storagetransfer/v1/internal/storage_transfer_connection_impl.h +++ b/google/cloud/storagetransfer/v1/internal/storage_transfer_connection_impl.h @@ -115,6 +115,15 @@ class StorageTransferServiceConnectionImpl google::storagetransfer::v1::DeleteAgentPoolRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr diff --git a/google/cloud/storagetransfer/v1/internal/storage_transfer_logging_decorator.cc b/google/cloud/storagetransfer/v1/internal/storage_transfer_logging_decorator.cc index 24fe3bc2e0b9f..99e198e759bcc 100644 --- a/google/cloud/storagetransfer/v1/internal/storage_transfer_logging_decorator.cc +++ b/google/cloud/storagetransfer/v1/internal/storage_transfer_logging_decorator.cc @@ -233,6 +233,41 @@ Status StorageTransferServiceLogging::DeleteAgentPool( context, options, request, __func__, tracing_options_); } +StatusOr +StorageTransferServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +StorageTransferServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status StorageTransferServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> StorageTransferServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/storagetransfer/v1/internal/storage_transfer_logging_decorator.h b/google/cloud/storagetransfer/v1/internal/storage_transfer_logging_decorator.h index e8d9ae89230b8..1b4621d32c0c2 100644 --- a/google/cloud/storagetransfer/v1/internal/storage_transfer_logging_decorator.h +++ b/google/cloud/storagetransfer/v1/internal/storage_transfer_logging_decorator.h @@ -116,6 +116,18 @@ class StorageTransferServiceLogging : public StorageTransferServiceStub { google::storagetransfer::v1::DeleteAgentPoolRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/storagetransfer/v1/internal/storage_transfer_metadata_decorator.cc b/google/cloud/storagetransfer/v1/internal/storage_transfer_metadata_decorator.cc index 3f2ef8fa0a30e..be30ce8d9c5f9 100644 --- a/google/cloud/storagetransfer/v1/internal/storage_transfer_metadata_decorator.cc +++ b/google/cloud/storagetransfer/v1/internal/storage_transfer_metadata_decorator.cc @@ -187,6 +187,32 @@ Status StorageTransferServiceMetadata::DeleteAgentPool( return child_->DeleteAgentPool(context, options, request); } +StatusOr +StorageTransferServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +StorageTransferServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status StorageTransferServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + future> StorageTransferServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/storagetransfer/v1/internal/storage_transfer_metadata_decorator.h b/google/cloud/storagetransfer/v1/internal/storage_transfer_metadata_decorator.h index 20ed511c64875..ba81033ee6565 100644 --- a/google/cloud/storagetransfer/v1/internal/storage_transfer_metadata_decorator.h +++ b/google/cloud/storagetransfer/v1/internal/storage_transfer_metadata_decorator.h @@ -117,6 +117,18 @@ class StorageTransferServiceMetadata : public StorageTransferServiceStub { google::storagetransfer::v1::DeleteAgentPoolRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/storagetransfer/v1/internal/storage_transfer_stub.cc b/google/cloud/storagetransfer/v1/internal/storage_transfer_stub.cc index d0aa82f9cd3d9..760bf2d97c672 100644 --- a/google/cloud/storagetransfer/v1/internal/storage_transfer_stub.cc +++ b/google/cloud/storagetransfer/v1/internal/storage_transfer_stub.cc @@ -218,6 +218,41 @@ Status DefaultStorageTransferServiceStub::DeleteAgentPool( return google::cloud::Status(); } +StatusOr +DefaultStorageTransferServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultStorageTransferServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultStorageTransferServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + future> DefaultStorageTransferServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/storagetransfer/v1/internal/storage_transfer_stub.h b/google/cloud/storagetransfer/v1/internal/storage_transfer_stub.h index 490c073d6261d..f175c8b662cb9 100644 --- a/google/cloud/storagetransfer/v1/internal/storage_transfer_stub.h +++ b/google/cloud/storagetransfer/v1/internal/storage_transfer_stub.h @@ -106,6 +106,18 @@ class StorageTransferServiceStub { grpc::ClientContext& context, Options const& options, google::storagetransfer::v1::DeleteAgentPoolRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -125,9 +137,13 @@ class DefaultStorageTransferServiceStub : public StorageTransferServiceStub { std::unique_ptr< google::storagetransfer::v1::StorageTransferService::StubInterface> grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr GetGoogleServiceAccount( @@ -206,6 +222,18 @@ class DefaultStorageTransferServiceStub : public StorageTransferServiceStub { google::storagetransfer::v1::DeleteAgentPoolRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -222,6 +250,8 @@ class DefaultStorageTransferServiceStub : public StorageTransferServiceStub { std::unique_ptr< google::storagetransfer::v1::StorageTransferService::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/storagetransfer/v1/internal/storage_transfer_stub_factory.cc b/google/cloud/storagetransfer/v1/internal/storage_transfer_stub_factory.cc index ba514c0e4e199..50587bb64dcd5 100644 --- a/google/cloud/storagetransfer/v1/internal/storage_transfer_stub_factory.cc +++ b/google/cloud/storagetransfer/v1/internal/storage_transfer_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 @@ CreateDefaultStorageTransferServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::storagetransfer::v1::StorageTransferService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/storagetransfer/v1/internal/storage_transfer_tracing_connection.cc b/google/cloud/storagetransfer/v1/internal/storage_transfer_tracing_connection.cc index eff0657fc7ecd..c8ce2fb649203 100644 --- a/google/cloud/storagetransfer/v1/internal/storage_transfer_tracing_connection.cc +++ b/google/cloud/storagetransfer/v1/internal/storage_transfer_tracing_connection.cc @@ -189,6 +189,34 @@ Status StorageTransferServiceTracingConnection::DeleteAgentPool( return internal::EndSpan(*span, child_->DeleteAgentPool(request)); } +StreamRange +StorageTransferServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "storagetransfer_v1::StorageTransferServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +StorageTransferServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "storagetransfer_v1::StorageTransferServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status StorageTransferServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "storagetransfer_v1::StorageTransferServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/storagetransfer/v1/internal/storage_transfer_tracing_connection.h b/google/cloud/storagetransfer/v1/internal/storage_transfer_tracing_connection.h index 565f4cd529f79..068ec7892dcf3 100644 --- a/google/cloud/storagetransfer/v1/internal/storage_transfer_tracing_connection.h +++ b/google/cloud/storagetransfer/v1/internal/storage_transfer_tracing_connection.h @@ -103,6 +103,15 @@ class StorageTransferServiceTracingConnection google::storagetransfer::v1::DeleteAgentPoolRequest const& request) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/storagetransfer/v1/internal/storage_transfer_tracing_stub.cc b/google/cloud/storagetransfer/v1/internal/storage_transfer_tracing_stub.cc index 3562cfdc16b18..7b9b79cda40eb 100644 --- a/google/cloud/storagetransfer/v1/internal/storage_transfer_tracing_stub.cc +++ b/google/cloud/storagetransfer/v1/internal/storage_transfer_tracing_stub.cc @@ -219,6 +219,41 @@ Status StorageTransferServiceTracingStub::DeleteAgentPool( child_->DeleteAgentPool(context, options, request)); } +StatusOr +StorageTransferServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.storagetransfer.v1.StorageTransferService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +StorageTransferServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.storagetransfer.v1.StorageTransferService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status StorageTransferServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.storagetransfer.v1.StorageTransferService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + future> StorageTransferServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/storagetransfer/v1/internal/storage_transfer_tracing_stub.h b/google/cloud/storagetransfer/v1/internal/storage_transfer_tracing_stub.h index c4f6be3d5c5bf..e46afb82b3bde 100644 --- a/google/cloud/storagetransfer/v1/internal/storage_transfer_tracing_stub.h +++ b/google/cloud/storagetransfer/v1/internal/storage_transfer_tracing_stub.h @@ -116,6 +116,18 @@ class StorageTransferServiceTracingStub : public StorageTransferServiceStub { google::storagetransfer::v1::DeleteAgentPoolRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/storagetransfer/v1/mocks/mock_storage_transfer_connection.h b/google/cloud/storagetransfer/v1/mocks/mock_storage_transfer_connection.h index c2f7b035d4f34..190880cc99a91 100644 --- a/google/cloud/storagetransfer/v1/mocks/mock_storage_transfer_connection.h +++ b/google/cloud/storagetransfer/v1/mocks/mock_storage_transfer_connection.h @@ -152,6 +152,17 @@ class MockStorageTransferServiceConnection Status, DeleteAgentPool, (google::storagetransfer::v1::DeleteAgentPoolRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/storagetransfer/v1/storage_transfer_client.cc b/google/cloud/storagetransfer/v1/storage_transfer_client.cc index 16704d6234692..489b7feafb827 100644 --- a/google/cloud/storagetransfer/v1/storage_transfer_client.cc +++ b/google/cloud/storagetransfer/v1/storage_transfer_client.cc @@ -205,6 +205,54 @@ Status StorageTransferServiceClient::DeleteAgentPool( return connection_->DeleteAgentPool(request); } +StreamRange +StorageTransferServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +StorageTransferServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +StorageTransferServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +StorageTransferServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status StorageTransferServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status StorageTransferServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace storagetransfer_v1 } // namespace cloud diff --git a/google/cloud/storagetransfer/v1/storage_transfer_client.h b/google/cloud/storagetransfer/v1/storage_transfer_client.h index 81005b88bdcc0..1a001e85f3d6b 100644 --- a/google/cloud/storagetransfer/v1/storage_transfer_client.h +++ b/google/cloud/storagetransfer/v1/storage_transfer_client.h @@ -764,6 +764,231 @@ class StorageTransferServiceClient { google::storagetransfer::v1::DeleteAgentPoolRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/storagetransfer/v1/storage_transfer_connection.cc b/google/cloud/storagetransfer/v1/storage_transfer_connection.cc index 7000e0785a980..926daedbae457 100644 --- a/google/cloud/storagetransfer/v1/storage_transfer_connection.cc +++ b/google/cloud/storagetransfer/v1/storage_transfer_connection.cc @@ -139,6 +139,25 @@ Status StorageTransferServiceConnection::DeleteAgentPool( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +StorageTransferServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +StorageTransferServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status StorageTransferServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeStorageTransferServiceConnection(Options options) { internal::CheckExpectedOptions ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/storagetransfer/v1/storage_transfer_connection_idempotency_policy.cc b/google/cloud/storagetransfer/v1/storage_transfer_connection_idempotency_policy.cc index 38ead89b2c9fc..125f00cde4f77 100644 --- a/google/cloud/storagetransfer/v1/storage_transfer_connection_idempotency_policy.cc +++ b/google/cloud/storagetransfer/v1/storage_transfer_connection_idempotency_policy.cc @@ -111,6 +111,21 @@ Idempotency StorageTransferServiceConnectionIdempotencyPolicy::DeleteAgentPool( return Idempotency::kNonIdempotent; } +Idempotency StorageTransferServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency StorageTransferServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency StorageTransferServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultStorageTransferServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/storagetransfer/v1/storage_transfer_connection_idempotency_policy.h b/google/cloud/storagetransfer/v1/storage_transfer_connection_idempotency_policy.h index 1384e88ec28fb..82ae504adfb24 100644 --- a/google/cloud/storagetransfer/v1/storage_transfer_connection_idempotency_policy.h +++ b/google/cloud/storagetransfer/v1/storage_transfer_connection_idempotency_policy.h @@ -21,6 +21,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -81,6 +82,15 @@ class StorageTransferServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteAgentPool( google::storagetransfer::v1::DeleteAgentPoolRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/talent/v4/company_client.cc b/google/cloud/talent/v4/company_client.cc index 75ee78bf06199..fb73e04c224c0 100644 --- a/google/cloud/talent/v4/company_client.cc +++ b/google/cloud/talent/v4/company_client.cc @@ -114,6 +114,20 @@ CompanyServiceClient::ListCompanies( return connection_->ListCompanies(std::move(request)); } +StatusOr CompanyServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr CompanyServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace talent_v4 } // namespace cloud diff --git a/google/cloud/talent/v4/company_client.h b/google/cloud/talent/v4/company_client.h index 451694a90ffea..d6191dcae81d3 100644 --- a/google/cloud/talent/v4/company_client.h +++ b/google/cloud/talent/v4/company_client.h @@ -408,6 +408,66 @@ class CompanyServiceClient { google::cloud::talent::v4::ListCompaniesRequest request, Options opts = {}); + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/talent/v4/company_connection.cc b/google/cloud/talent/v4/company_connection.cc index 6892363e54a68..cc855e7ba6d2f 100644 --- a/google/cloud/talent/v4/company_connection.cc +++ b/google/cloud/talent/v4/company_connection.cc @@ -69,6 +69,11 @@ CompanyServiceConnection::ListCompanies( StreamRange>(); } +StatusOr CompanyServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeCompanyServiceConnection( Options options) { internal::CheckExpectedOptions ListCompanies( google::cloud::talent::v4::ListCompaniesRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/talent/v4/company_connection_idempotency_policy.cc b/google/cloud/talent/v4/company_connection_idempotency_policy.cc index b02a41ef95f05..68105ef4b1341 100644 --- a/google/cloud/talent/v4/company_connection_idempotency_policy.cc +++ b/google/cloud/talent/v4/company_connection_idempotency_policy.cc @@ -59,6 +59,11 @@ Idempotency CompanyServiceConnectionIdempotencyPolicy::ListCompanies( return Idempotency::kIdempotent; } +Idempotency CompanyServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultCompanyServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/talent/v4/company_connection_idempotency_policy.h b/google/cloud/talent/v4/company_connection_idempotency_policy.h index b3e6d3f21b3b3..3217d473b0618 100644 --- a/google/cloud/talent/v4/company_connection_idempotency_policy.h +++ b/google/cloud/talent/v4/company_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,9 @@ class CompanyServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListCompanies( google::cloud::talent::v4::ListCompaniesRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/talent/v4/completion_client.cc b/google/cloud/talent/v4/completion_client.cc index 6a81f8f509a48..330e261cde992 100644 --- a/google/cloud/talent/v4/completion_client.cc +++ b/google/cloud/talent/v4/completion_client.cc @@ -40,6 +40,20 @@ CompletionClient::CompleteQuery( return connection_->CompleteQuery(request); } +StatusOr CompletionClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr CompletionClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace talent_v4 } // namespace cloud diff --git a/google/cloud/talent/v4/completion_client.h b/google/cloud/talent/v4/completion_client.h index e5dd2b3066d41..ed191674ff6f1 100644 --- a/google/cloud/talent/v4/completion_client.h +++ b/google/cloud/talent/v4/completion_client.h @@ -115,6 +115,66 @@ class CompletionClient { google::cloud::talent::v4::CompleteQueryRequest const& request, Options opts = {}); + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/talent/v4/completion_connection.cc b/google/cloud/talent/v4/completion_connection.cc index fff3e0bcc487c..bba6f2376bed3 100644 --- a/google/cloud/talent/v4/completion_connection.cc +++ b/google/cloud/talent/v4/completion_connection.cc @@ -43,6 +43,11 @@ CompletionConnection::CompleteQuery( return Status(StatusCode::kUnimplemented, "not implemented"); } +StatusOr CompletionConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeCompletionConnection( Options options) { internal::CheckExpectedOptions CompleteQuery(google::cloud::talent::v4::CompleteQueryRequest const& request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/talent/v4/completion_connection_idempotency_policy.cc b/google/cloud/talent/v4/completion_connection_idempotency_policy.cc index 81d9ed945c941..675def011ff0f 100644 --- a/google/cloud/talent/v4/completion_connection_idempotency_policy.cc +++ b/google/cloud/talent/v4/completion_connection_idempotency_policy.cc @@ -39,6 +39,11 @@ Idempotency CompletionConnectionIdempotencyPolicy::CompleteQuery( return Idempotency::kIdempotent; } +Idempotency CompletionConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultCompletionConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/talent/v4/completion_connection_idempotency_policy.h b/google/cloud/talent/v4/completion_connection_idempotency_policy.h index 3c77b46e20d81..e5b5e9ffe0054 100644 --- a/google/cloud/talent/v4/completion_connection_idempotency_policy.h +++ b/google/cloud/talent/v4/completion_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,9 @@ class CompletionConnectionIdempotencyPolicy { virtual google::cloud::Idempotency CompleteQuery( google::cloud::talent::v4::CompleteQueryRequest const& request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/talent/v4/event_client.cc b/google/cloud/talent/v4/event_client.cc index 4a466e4f7c979..de79fbf91d3c2 100644 --- a/google/cloud/talent/v4/event_client.cc +++ b/google/cloud/talent/v4/event_client.cc @@ -51,6 +51,20 @@ EventServiceClient::CreateClientEvent( return connection_->CreateClientEvent(request); } +StatusOr EventServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr EventServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace talent_v4 } // namespace cloud diff --git a/google/cloud/talent/v4/event_client.h b/google/cloud/talent/v4/event_client.h index 6f6bdac8358c3..da07d91a98039 100644 --- a/google/cloud/talent/v4/event_client.h +++ b/google/cloud/talent/v4/event_client.h @@ -160,6 +160,66 @@ class EventServiceClient { google::cloud::talent::v4::CreateClientEventRequest const& request, Options opts = {}); + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/talent/v4/event_connection.cc b/google/cloud/talent/v4/event_connection.cc index ea9428a4188f6..c9bd3edbee04e 100644 --- a/google/cloud/talent/v4/event_connection.cc +++ b/google/cloud/talent/v4/event_connection.cc @@ -43,6 +43,11 @@ EventServiceConnection::CreateClientEvent( return Status(StatusCode::kUnimplemented, "not implemented"); } +StatusOr EventServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeEventServiceConnection( Options options) { internal::CheckExpectedOptions CreateClientEvent( google::cloud::talent::v4::CreateClientEventRequest const& request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/talent/v4/event_connection_idempotency_policy.cc b/google/cloud/talent/v4/event_connection_idempotency_policy.cc index 08d3bdac1f1cd..fc1c55f4868bc 100644 --- a/google/cloud/talent/v4/event_connection_idempotency_policy.cc +++ b/google/cloud/talent/v4/event_connection_idempotency_policy.cc @@ -39,6 +39,11 @@ Idempotency EventServiceConnectionIdempotencyPolicy::CreateClientEvent( return Idempotency::kNonIdempotent; } +Idempotency EventServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultEventServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/talent/v4/event_connection_idempotency_policy.h b/google/cloud/talent/v4/event_connection_idempotency_policy.h index e6a0300219133..72e1210d03591 100644 --- a/google/cloud/talent/v4/event_connection_idempotency_policy.h +++ b/google/cloud/talent/v4/event_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -39,6 +40,9 @@ class EventServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency CreateClientEvent( google::cloud::talent::v4::CreateClientEventRequest const& request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/talent/v4/internal/company_auth_decorator.cc b/google/cloud/talent/v4/internal/company_auth_decorator.cc index 33ed2fcee0180..d69fb0b517c63 100644 --- a/google/cloud/talent/v4/internal/company_auth_decorator.cc +++ b/google/cloud/talent/v4/internal/company_auth_decorator.cc @@ -72,6 +72,14 @@ CompanyServiceAuth::ListCompanies( return child_->ListCompanies(context, options, request); } +StatusOr CompanyServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace talent_v4_internal } // namespace cloud diff --git a/google/cloud/talent/v4/internal/company_auth_decorator.h b/google/cloud/talent/v4/internal/company_auth_decorator.h index 7c52680dd5162..891093c788a02 100644 --- a/google/cloud/talent/v4/internal/company_auth_decorator.h +++ b/google/cloud/talent/v4/internal/company_auth_decorator.h @@ -58,6 +58,10 @@ class CompanyServiceAuth : public CompanyServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::talent::v4::ListCompaniesRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/talent/v4/internal/company_connection_impl.cc b/google/cloud/talent/v4/internal/company_connection_impl.cc index 28f17acbe252e..bcd2e3329512a 100644 --- a/google/cloud/talent/v4/internal/company_connection_impl.cc +++ b/google/cloud/talent/v4/internal/company_connection_impl.cc @@ -148,6 +148,20 @@ CompanyServiceConnectionImpl::ListCompanies( }); } +StatusOr +CompanyServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace talent_v4_internal } // namespace cloud diff --git a/google/cloud/talent/v4/internal/company_connection_impl.h b/google/cloud/talent/v4/internal/company_connection_impl.h index 3bb8289ce27b8..5cb2ae43413de 100644 --- a/google/cloud/talent/v4/internal/company_connection_impl.h +++ b/google/cloud/talent/v4/internal/company_connection_impl.h @@ -64,6 +64,9 @@ class CompanyServiceConnectionImpl StreamRange ListCompanies( google::cloud::talent::v4::ListCompaniesRequest request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/talent/v4/internal/company_logging_decorator.cc b/google/cloud/talent/v4/internal/company_logging_decorator.cc index 6e1e24f6f95c7..ad8e0c83a1854 100644 --- a/google/cloud/talent/v4/internal/company_logging_decorator.cc +++ b/google/cloud/talent/v4/internal/company_logging_decorator.cc @@ -93,6 +93,17 @@ CompanyServiceLogging::ListCompanies( context, options, request, __func__, tracing_options_); } +StatusOr CompanyServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace talent_v4_internal } // namespace cloud diff --git a/google/cloud/talent/v4/internal/company_logging_decorator.h b/google/cloud/talent/v4/internal/company_logging_decorator.h index 19b258c2a44a3..469c6e537e4db 100644 --- a/google/cloud/talent/v4/internal/company_logging_decorator.h +++ b/google/cloud/talent/v4/internal/company_logging_decorator.h @@ -58,6 +58,10 @@ class CompanyServiceLogging : public CompanyServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::talent::v4::ListCompaniesRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/talent/v4/internal/company_metadata_decorator.cc b/google/cloud/talent/v4/internal/company_metadata_decorator.cc index 1642a41ee8cf1..16e73d3e9e241 100644 --- a/google/cloud/talent/v4/internal/company_metadata_decorator.cc +++ b/google/cloud/talent/v4/internal/company_metadata_decorator.cc @@ -88,6 +88,14 @@ CompanyServiceMetadata::ListCompanies( return child_->ListCompanies(context, options, request); } +StatusOr CompanyServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + void CompanyServiceMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/talent/v4/internal/company_metadata_decorator.h b/google/cloud/talent/v4/internal/company_metadata_decorator.h index 38cc185169a99..64f9fd32eefb5 100644 --- a/google/cloud/talent/v4/internal/company_metadata_decorator.h +++ b/google/cloud/talent/v4/internal/company_metadata_decorator.h @@ -58,6 +58,10 @@ class CompanyServiceMetadata : public CompanyServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::talent::v4::ListCompaniesRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/talent/v4/internal/company_stub.cc b/google/cloud/talent/v4/internal/company_stub.cc index 8fa4204bc992b..6554d558b48ea 100644 --- a/google/cloud/talent/v4/internal/company_stub.cc +++ b/google/cloud/talent/v4/internal/company_stub.cc @@ -89,6 +89,18 @@ DefaultCompanyServiceStub::ListCompanies( return response; } +StatusOr +DefaultCompanyServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace talent_v4_internal } // namespace cloud diff --git a/google/cloud/talent/v4/internal/company_stub.h b/google/cloud/talent/v4/internal/company_stub.h index b8cfd34c74a7a..4b8f909978a87 100644 --- a/google/cloud/talent/v4/internal/company_stub.h +++ b/google/cloud/talent/v4/internal/company_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -55,14 +56,21 @@ class CompanyServiceStub { ListCompanies( grpc::ClientContext& context, Options const& options, google::cloud::talent::v4::ListCompaniesRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; }; class DefaultCompanyServiceStub : public CompanyServiceStub { public: explicit DefaultCompanyServiceStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr CreateCompany( grpc::ClientContext& context, Options const& options, @@ -84,9 +92,15 @@ class DefaultCompanyServiceStub : public CompanyServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::talent::v4::ListCompaniesRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/talent/v4/internal/company_stub_factory.cc b/google/cloud/talent/v4/internal/company_stub_factory.cc index 3e54717ccc159..e68f2c8d0d6dd 100644 --- a/google/cloud/talent/v4/internal/company_stub_factory.cc +++ b/google/cloud/talent/v4/internal/company_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 CreateDefaultCompanyServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::talent::v4::CompanyService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_stub)); if (auth->RequiresConfigureContext()) { stub = diff --git a/google/cloud/talent/v4/internal/company_tracing_connection.cc b/google/cloud/talent/v4/internal/company_tracing_connection.cc index 11ff98caed79f..7e1906e83ec85 100644 --- a/google/cloud/talent/v4/internal/company_tracing_connection.cc +++ b/google/cloud/talent/v4/internal/company_tracing_connection.cc @@ -79,6 +79,15 @@ CompanyServiceTracingConnection::ListCompanies( std::move(span), std::move(sr)); } +StatusOr +CompanyServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("talent_v4::CompanyServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/talent/v4/internal/company_tracing_connection.h b/google/cloud/talent/v4/internal/company_tracing_connection.h index 8a573ffc83b4b..63f3776f02ae3 100644 --- a/google/cloud/talent/v4/internal/company_tracing_connection.h +++ b/google/cloud/talent/v4/internal/company_tracing_connection.h @@ -55,6 +55,9 @@ class CompanyServiceTracingConnection StreamRange ListCompanies( google::cloud::talent::v4::ListCompaniesRequest request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/talent/v4/internal/company_tracing_stub.cc b/google/cloud/talent/v4/internal/company_tracing_stub.cc index c613231ad6fe3..c45671a015d1f 100644 --- a/google/cloud/talent/v4/internal/company_tracing_stub.cc +++ b/google/cloud/talent/v4/internal/company_tracing_stub.cc @@ -91,6 +91,18 @@ CompanyServiceTracingStub::ListCompanies( child_->ListCompanies(context, options, request)); } +StatusOr +CompanyServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.talent.v4.CompanyService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeCompanyServiceTracingStub( diff --git a/google/cloud/talent/v4/internal/company_tracing_stub.h b/google/cloud/talent/v4/internal/company_tracing_stub.h index acf72d7ae91fe..4c272fcea5e7e 100644 --- a/google/cloud/talent/v4/internal/company_tracing_stub.h +++ b/google/cloud/talent/v4/internal/company_tracing_stub.h @@ -58,6 +58,10 @@ class CompanyServiceTracingStub : public CompanyServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::talent::v4::ListCompaniesRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/talent/v4/internal/completion_auth_decorator.cc b/google/cloud/talent/v4/internal/completion_auth_decorator.cc index 3f1bce1a13951..b53ab9651272a 100644 --- a/google/cloud/talent/v4/internal/completion_auth_decorator.cc +++ b/google/cloud/talent/v4/internal/completion_auth_decorator.cc @@ -40,6 +40,14 @@ CompletionAuth::CompleteQuery( return child_->CompleteQuery(context, options, request); } +StatusOr CompletionAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace talent_v4_internal } // namespace cloud diff --git a/google/cloud/talent/v4/internal/completion_auth_decorator.h b/google/cloud/talent/v4/internal/completion_auth_decorator.h index 852ad989c5ef8..49c4042e20737 100644 --- a/google/cloud/talent/v4/internal/completion_auth_decorator.h +++ b/google/cloud/talent/v4/internal/completion_auth_decorator.h @@ -42,6 +42,10 @@ class CompletionAuth : public CompletionStub { grpc::ClientContext& context, Options const& options, google::cloud::talent::v4::CompleteQueryRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/talent/v4/internal/completion_connection_impl.cc b/google/cloud/talent/v4/internal/completion_connection_impl.cc index 32f9f716a75c1..4d892428ed0e4 100644 --- a/google/cloud/talent/v4/internal/completion_connection_impl.cc +++ b/google/cloud/talent/v4/internal/completion_connection_impl.cc @@ -70,6 +70,19 @@ CompletionConnectionImpl::CompleteQuery( *current, request, __func__); } +StatusOr CompletionConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace talent_v4_internal } // namespace cloud diff --git a/google/cloud/talent/v4/internal/completion_connection_impl.h b/google/cloud/talent/v4/internal/completion_connection_impl.h index 3fe3f355a2b30..565c533fbb409 100644 --- a/google/cloud/talent/v4/internal/completion_connection_impl.h +++ b/google/cloud/talent/v4/internal/completion_connection_impl.h @@ -50,6 +50,9 @@ class CompletionConnectionImpl : public talent_v4::CompletionConnection { StatusOr CompleteQuery( google::cloud::talent::v4::CompleteQueryRequest const& request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/talent/v4/internal/completion_logging_decorator.cc b/google/cloud/talent/v4/internal/completion_logging_decorator.cc index d8f594db5e4ed..f9ea46b49d42c 100644 --- a/google/cloud/talent/v4/internal/completion_logging_decorator.cc +++ b/google/cloud/talent/v4/internal/completion_logging_decorator.cc @@ -47,6 +47,17 @@ CompletionLogging::CompleteQuery( context, options, request, __func__, tracing_options_); } +StatusOr CompletionLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace talent_v4_internal } // namespace cloud diff --git a/google/cloud/talent/v4/internal/completion_logging_decorator.h b/google/cloud/talent/v4/internal/completion_logging_decorator.h index c5e606b2222e1..b08957903e1d0 100644 --- a/google/cloud/talent/v4/internal/completion_logging_decorator.h +++ b/google/cloud/talent/v4/internal/completion_logging_decorator.h @@ -42,6 +42,10 @@ class CompletionLogging : public CompletionStub { grpc::ClientContext& context, Options const& options, google::cloud::talent::v4::CompleteQueryRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/talent/v4/internal/completion_metadata_decorator.cc b/google/cloud/talent/v4/internal/completion_metadata_decorator.cc index 1772103bd04ae..901b314f30d73 100644 --- a/google/cloud/talent/v4/internal/completion_metadata_decorator.cc +++ b/google/cloud/talent/v4/internal/completion_metadata_decorator.cc @@ -53,6 +53,14 @@ CompletionMetadata::CompleteQuery( return child_->CompleteQuery(context, options, request); } +StatusOr CompletionMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + void CompletionMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/talent/v4/internal/completion_metadata_decorator.h b/google/cloud/talent/v4/internal/completion_metadata_decorator.h index 6e583075d1868..8cdf183cde244 100644 --- a/google/cloud/talent/v4/internal/completion_metadata_decorator.h +++ b/google/cloud/talent/v4/internal/completion_metadata_decorator.h @@ -42,6 +42,10 @@ class CompletionMetadata : public CompletionStub { grpc::ClientContext& context, Options const& options, google::cloud::talent::v4::CompleteQueryRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/talent/v4/internal/completion_stub.cc b/google/cloud/talent/v4/internal/completion_stub.cc index 44c924ea4cd5b..c065b83bec82a 100644 --- a/google/cloud/talent/v4/internal/completion_stub.cc +++ b/google/cloud/talent/v4/internal/completion_stub.cc @@ -42,6 +42,17 @@ DefaultCompletionStub::CompleteQuery( return response; } +StatusOr DefaultCompletionStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace talent_v4_internal } // namespace cloud diff --git a/google/cloud/talent/v4/internal/completion_stub.h b/google/cloud/talent/v4/internal/completion_stub.h index 5a2dda7a0b472..518fecf31f2c0 100644 --- a/google/cloud/talent/v4/internal/completion_stub.h +++ b/google/cloud/talent/v4/internal/completion_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -39,22 +40,35 @@ class CompletionStub { CompleteQuery( grpc::ClientContext& context, Options const& options, google::cloud::talent::v4::CompleteQueryRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; }; class DefaultCompletionStub : public CompletionStub { public: explicit DefaultCompletionStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr CompleteQuery( grpc::ClientContext& context, Options const& options, google::cloud::talent::v4::CompleteQueryRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/talent/v4/internal/completion_stub_factory.cc b/google/cloud/talent/v4/internal/completion_stub_factory.cc index f6ead6f70ccd7..828dce1b79fc3 100644 --- a/google/cloud/talent/v4/internal/completion_stub_factory.cc +++ b/google/cloud/talent/v4/internal/completion_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 CreateDefaultCompletionStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::talent::v4::Completion::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), std::move(stub)); diff --git a/google/cloud/talent/v4/internal/completion_tracing_connection.cc b/google/cloud/talent/v4/internal/completion_tracing_connection.cc index 046104fe01471..851a30e6d18fa 100644 --- a/google/cloud/talent/v4/internal/completion_tracing_connection.cc +++ b/google/cloud/talent/v4/internal/completion_tracing_connection.cc @@ -41,6 +41,15 @@ CompletionTracingConnection::CompleteQuery( return internal::EndSpan(*span, child_->CompleteQuery(request)); } +StatusOr +CompletionTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("talent_v4::CompletionConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/talent/v4/internal/completion_tracing_connection.h b/google/cloud/talent/v4/internal/completion_tracing_connection.h index 9a69ad66351d4..9aeca23c96644 100644 --- a/google/cloud/talent/v4/internal/completion_tracing_connection.h +++ b/google/cloud/talent/v4/internal/completion_tracing_connection.h @@ -42,6 +42,9 @@ class CompletionTracingConnection : public talent_v4::CompletionConnection { StatusOr CompleteQuery( google::cloud::talent::v4::CompleteQueryRequest const& request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/talent/v4/internal/completion_tracing_stub.cc b/google/cloud/talent/v4/internal/completion_tracing_stub.cc index d174c67f9624c..c642881a0e2d2 100644 --- a/google/cloud/talent/v4/internal/completion_tracing_stub.cc +++ b/google/cloud/talent/v4/internal/completion_tracing_stub.cc @@ -44,6 +44,17 @@ CompletionTracingStub::CompleteQuery( child_->CompleteQuery(context, options, request)); } +StatusOr CompletionTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.talent.v4.Completion", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeCompletionTracingStub( diff --git a/google/cloud/talent/v4/internal/completion_tracing_stub.h b/google/cloud/talent/v4/internal/completion_tracing_stub.h index 4fedd54134cb8..04d87fde0f925 100644 --- a/google/cloud/talent/v4/internal/completion_tracing_stub.h +++ b/google/cloud/talent/v4/internal/completion_tracing_stub.h @@ -42,6 +42,10 @@ class CompletionTracingStub : public CompletionStub { grpc::ClientContext& context, Options const& options, google::cloud::talent::v4::CompleteQueryRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/talent/v4/internal/event_auth_decorator.cc b/google/cloud/talent/v4/internal/event_auth_decorator.cc index f679f1a5a63a8..43c16287f515f 100644 --- a/google/cloud/talent/v4/internal/event_auth_decorator.cc +++ b/google/cloud/talent/v4/internal/event_auth_decorator.cc @@ -40,6 +40,14 @@ EventServiceAuth::CreateClientEvent( return child_->CreateClientEvent(context, options, request); } +StatusOr EventServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace talent_v4_internal } // namespace cloud diff --git a/google/cloud/talent/v4/internal/event_auth_decorator.h b/google/cloud/talent/v4/internal/event_auth_decorator.h index f013b004f8ae8..122b63876d37c 100644 --- a/google/cloud/talent/v4/internal/event_auth_decorator.h +++ b/google/cloud/talent/v4/internal/event_auth_decorator.h @@ -43,6 +43,10 @@ class EventServiceAuth : public EventServiceStub { google::cloud::talent::v4::CreateClientEventRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/talent/v4/internal/event_connection_impl.cc b/google/cloud/talent/v4/internal/event_connection_impl.cc index a71429cb2d440..a3d6bd7a92a4b 100644 --- a/google/cloud/talent/v4/internal/event_connection_impl.cc +++ b/google/cloud/talent/v4/internal/event_connection_impl.cc @@ -72,6 +72,20 @@ EventServiceConnectionImpl::CreateClientEvent( *current, request, __func__); } +StatusOr +EventServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace talent_v4_internal } // namespace cloud diff --git a/google/cloud/talent/v4/internal/event_connection_impl.h b/google/cloud/talent/v4/internal/event_connection_impl.h index 6ad8fea1598fc..b6fd946c6df62 100644 --- a/google/cloud/talent/v4/internal/event_connection_impl.h +++ b/google/cloud/talent/v4/internal/event_connection_impl.h @@ -51,6 +51,9 @@ class EventServiceConnectionImpl : public talent_v4::EventServiceConnection { google::cloud::talent::v4::CreateClientEventRequest const& request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/talent/v4/internal/event_logging_decorator.cc b/google/cloud/talent/v4/internal/event_logging_decorator.cc index 205024f34cf8a..e0b06943bd7bb 100644 --- a/google/cloud/talent/v4/internal/event_logging_decorator.cc +++ b/google/cloud/talent/v4/internal/event_logging_decorator.cc @@ -48,6 +48,17 @@ EventServiceLogging::CreateClientEvent( context, options, request, __func__, tracing_options_); } +StatusOr EventServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace talent_v4_internal } // namespace cloud diff --git a/google/cloud/talent/v4/internal/event_logging_decorator.h b/google/cloud/talent/v4/internal/event_logging_decorator.h index 8c1c2904fcd51..a5bf635de0233 100644 --- a/google/cloud/talent/v4/internal/event_logging_decorator.h +++ b/google/cloud/talent/v4/internal/event_logging_decorator.h @@ -43,6 +43,10 @@ class EventServiceLogging : public EventServiceStub { google::cloud::talent::v4::CreateClientEventRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/talent/v4/internal/event_metadata_decorator.cc b/google/cloud/talent/v4/internal/event_metadata_decorator.cc index a5620cd946233..9aad598193003 100644 --- a/google/cloud/talent/v4/internal/event_metadata_decorator.cc +++ b/google/cloud/talent/v4/internal/event_metadata_decorator.cc @@ -53,6 +53,14 @@ EventServiceMetadata::CreateClientEvent( return child_->CreateClientEvent(context, options, request); } +StatusOr EventServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + void EventServiceMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/talent/v4/internal/event_metadata_decorator.h b/google/cloud/talent/v4/internal/event_metadata_decorator.h index 3b4255b4b8a51..254f89c38446a 100644 --- a/google/cloud/talent/v4/internal/event_metadata_decorator.h +++ b/google/cloud/talent/v4/internal/event_metadata_decorator.h @@ -43,6 +43,10 @@ class EventServiceMetadata : public EventServiceStub { google::cloud::talent::v4::CreateClientEventRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/talent/v4/internal/event_stub.cc b/google/cloud/talent/v4/internal/event_stub.cc index 100fbc1834eca..43954946e5ecc 100644 --- a/google/cloud/talent/v4/internal/event_stub.cc +++ b/google/cloud/talent/v4/internal/event_stub.cc @@ -42,6 +42,17 @@ DefaultEventServiceStub::CreateClientEvent( return response; } +StatusOr DefaultEventServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace talent_v4_internal } // namespace cloud diff --git a/google/cloud/talent/v4/internal/event_stub.h b/google/cloud/talent/v4/internal/event_stub.h index cc89811ce926b..7ca65480661f9 100644 --- a/google/cloud/talent/v4/internal/event_stub.h +++ b/google/cloud/talent/v4/internal/event_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -38,23 +39,36 @@ class EventServiceStub { virtual StatusOr CreateClientEvent( grpc::ClientContext& context, Options const& options, google::cloud::talent::v4::CreateClientEventRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; }; class DefaultEventServiceStub : public EventServiceStub { public: explicit DefaultEventServiceStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr CreateClientEvent( grpc::ClientContext& context, Options const& options, google::cloud::talent::v4::CreateClientEventRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/talent/v4/internal/event_stub_factory.cc b/google/cloud/talent/v4/internal/event_stub_factory.cc index 78c97863a1459..a20eeedb68e17 100644 --- a/google/cloud/talent/v4/internal/event_stub_factory.cc +++ b/google/cloud/talent/v4/internal/event_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 CreateDefaultEventServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::talent::v4::EventService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), std::move(stub)); diff --git a/google/cloud/talent/v4/internal/event_tracing_connection.cc b/google/cloud/talent/v4/internal/event_tracing_connection.cc index 8a6ed601914ce..864acea8d2c4c 100644 --- a/google/cloud/talent/v4/internal/event_tracing_connection.cc +++ b/google/cloud/talent/v4/internal/event_tracing_connection.cc @@ -41,6 +41,15 @@ EventServiceTracingConnection::CreateClientEvent( return internal::EndSpan(*span, child_->CreateClientEvent(request)); } +StatusOr +EventServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("talent_v4::EventServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/talent/v4/internal/event_tracing_connection.h b/google/cloud/talent/v4/internal/event_tracing_connection.h index 0bcc626a9ad6d..2f3f420b83c0c 100644 --- a/google/cloud/talent/v4/internal/event_tracing_connection.h +++ b/google/cloud/talent/v4/internal/event_tracing_connection.h @@ -43,6 +43,9 @@ class EventServiceTracingConnection : public talent_v4::EventServiceConnection { google::cloud::talent::v4::CreateClientEventRequest const& request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/talent/v4/internal/event_tracing_stub.cc b/google/cloud/talent/v4/internal/event_tracing_stub.cc index 0dd9fa0c98dbe..6a15ffdb2b88f 100644 --- a/google/cloud/talent/v4/internal/event_tracing_stub.cc +++ b/google/cloud/talent/v4/internal/event_tracing_stub.cc @@ -44,6 +44,17 @@ EventServiceTracingStub::CreateClientEvent( context, *span, child_->CreateClientEvent(context, options, request)); } +StatusOr EventServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.talent.v4.EventService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeEventServiceTracingStub( diff --git a/google/cloud/talent/v4/internal/event_tracing_stub.h b/google/cloud/talent/v4/internal/event_tracing_stub.h index 5ae1a0bde8b2e..5acbdf9c69bb5 100644 --- a/google/cloud/talent/v4/internal/event_tracing_stub.h +++ b/google/cloud/talent/v4/internal/event_tracing_stub.h @@ -43,6 +43,10 @@ class EventServiceTracingStub : public EventServiceStub { google::cloud::talent::v4::CreateClientEventRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/talent/v4/internal/job_auth_decorator.cc b/google/cloud/talent/v4/internal/job_auth_decorator.cc index 6bade7e3066ae..fc45e1a6cebb3 100644 --- a/google/cloud/talent/v4/internal/job_auth_decorator.cc +++ b/google/cloud/talent/v4/internal/job_auth_decorator.cc @@ -173,6 +173,14 @@ JobServiceAuth::SearchJobsForAlert( return child_->SearchJobsForAlert(context, options, request); } +StatusOr JobServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + future> JobServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/talent/v4/internal/job_auth_decorator.h b/google/cloud/talent/v4/internal/job_auth_decorator.h index 15a0312220200..e8286beaea661 100644 --- a/google/cloud/talent/v4/internal/job_auth_decorator.h +++ b/google/cloud/talent/v4/internal/job_auth_decorator.h @@ -103,6 +103,10 @@ class JobServiceAuth : public JobServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::talent::v4::SearchJobsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/talent/v4/internal/job_connection_impl.cc b/google/cloud/talent/v4/internal/job_connection_impl.cc index bbb2c5ddfea42..dcf1a5706703d 100644 --- a/google/cloud/talent/v4/internal/job_connection_impl.cc +++ b/google/cloud/talent/v4/internal/job_connection_impl.cc @@ -446,6 +446,19 @@ JobServiceConnectionImpl::SearchJobsForAlert( *current, request, __func__); } +StatusOr JobServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace talent_v4_internal } // namespace cloud diff --git a/google/cloud/talent/v4/internal/job_connection_impl.h b/google/cloud/talent/v4/internal/job_connection_impl.h index 794065c1ee08f..55de5cf56ee85 100644 --- a/google/cloud/talent/v4/internal/job_connection_impl.h +++ b/google/cloud/talent/v4/internal/job_connection_impl.h @@ -108,6 +108,9 @@ class JobServiceConnectionImpl : public talent_v4::JobServiceConnection { StatusOr SearchJobsForAlert( google::cloud::talent::v4::SearchJobsRequest const& request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/talent/v4/internal/job_logging_decorator.cc b/google/cloud/talent/v4/internal/job_logging_decorator.cc index eb828d06c7aa9..8e2579ac8f998 100644 --- a/google/cloud/talent/v4/internal/job_logging_decorator.cc +++ b/google/cloud/talent/v4/internal/job_logging_decorator.cc @@ -202,6 +202,17 @@ JobServiceLogging::SearchJobsForAlert( context, options, request, __func__, tracing_options_); } +StatusOr JobServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> JobServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/talent/v4/internal/job_logging_decorator.h b/google/cloud/talent/v4/internal/job_logging_decorator.h index 7490413cc7f49..0094ef4c5f488 100644 --- a/google/cloud/talent/v4/internal/job_logging_decorator.h +++ b/google/cloud/talent/v4/internal/job_logging_decorator.h @@ -103,6 +103,10 @@ class JobServiceLogging : public JobServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::talent::v4::SearchJobsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/talent/v4/internal/job_metadata_decorator.cc b/google/cloud/talent/v4/internal/job_metadata_decorator.cc index c0d79a71399a6..54f9f5a2a8a63 100644 --- a/google/cloud/talent/v4/internal/job_metadata_decorator.cc +++ b/google/cloud/talent/v4/internal/job_metadata_decorator.cc @@ -164,6 +164,14 @@ JobServiceMetadata::SearchJobsForAlert( return child_->SearchJobsForAlert(context, options, request); } +StatusOr JobServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + future> JobServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/talent/v4/internal/job_metadata_decorator.h b/google/cloud/talent/v4/internal/job_metadata_decorator.h index a82c186b20148..2e39a03d6a0bb 100644 --- a/google/cloud/talent/v4/internal/job_metadata_decorator.h +++ b/google/cloud/talent/v4/internal/job_metadata_decorator.h @@ -103,6 +103,10 @@ class JobServiceMetadata : public JobServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::talent::v4::SearchJobsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/talent/v4/internal/job_stub.cc b/google/cloud/talent/v4/internal/job_stub.cc index 435f4fd969fd1..10545debcfd36 100644 --- a/google/cloud/talent/v4/internal/job_stub.cc +++ b/google/cloud/talent/v4/internal/job_stub.cc @@ -198,6 +198,17 @@ DefaultJobServiceStub::SearchJobsForAlert( return response; } +StatusOr DefaultJobServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&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/talent/v4/internal/job_stub.h b/google/cloud/talent/v4/internal/job_stub.h index a8217562dfe19..1b6290b9da37c 100644 --- a/google/cloud/talent/v4/internal/job_stub.h +++ b/google/cloud/talent/v4/internal/job_stub.h @@ -97,6 +97,10 @@ class JobServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::talent::v4::SearchJobsRequest const& request) = 0; + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -115,9 +119,13 @@ class DefaultJobServiceStub : public JobServiceStub { DefaultJobServiceStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr CreateJob( grpc::ClientContext& context, Options const& options, @@ -183,6 +191,10 @@ class DefaultJobServiceStub : public JobServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::talent::v4::SearchJobsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -198,6 +210,8 @@ class DefaultJobServiceStub : public JobServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/talent/v4/internal/job_stub_factory.cc b/google/cloud/talent/v4/internal/job_stub_factory.cc index 8b8f7d86ccafb..c3d1f089bf4ed 100644 --- a/google/cloud/talent/v4/internal/job_stub_factory.cc +++ b/google/cloud/talent/v4/internal/job_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 CreateDefaultJobServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::talent::v4::JobService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/talent/v4/internal/job_tracing_connection.cc b/google/cloud/talent/v4/internal/job_tracing_connection.cc index 901f83faf5301..aa68e00edf4eb 100644 --- a/google/cloud/talent/v4/internal/job_tracing_connection.cc +++ b/google/cloud/talent/v4/internal/job_tracing_connection.cc @@ -175,6 +175,15 @@ JobServiceTracingConnection::SearchJobsForAlert( return internal::EndSpan(*span, child_->SearchJobsForAlert(request)); } +StatusOr +JobServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("talent_v4::JobServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/talent/v4/internal/job_tracing_connection.h b/google/cloud/talent/v4/internal/job_tracing_connection.h index 68d555ed24096..520394d0137a1 100644 --- a/google/cloud/talent/v4/internal/job_tracing_connection.h +++ b/google/cloud/talent/v4/internal/job_tracing_connection.h @@ -96,6 +96,9 @@ class JobServiceTracingConnection : public talent_v4::JobServiceConnection { StatusOr SearchJobsForAlert( google::cloud::talent::v4::SearchJobsRequest const& request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/talent/v4/internal/job_tracing_stub.cc b/google/cloud/talent/v4/internal/job_tracing_stub.cc index bf9ccab0d8132..c9d5cef94253d 100644 --- a/google/cloud/talent/v4/internal/job_tracing_stub.cc +++ b/google/cloud/talent/v4/internal/job_tracing_stub.cc @@ -190,6 +190,17 @@ JobServiceTracingStub::SearchJobsForAlert( context, *span, child_->SearchJobsForAlert(context, options, request)); } +StatusOr JobServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.talent.v4.JobService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + future> JobServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/talent/v4/internal/job_tracing_stub.h b/google/cloud/talent/v4/internal/job_tracing_stub.h index 878ef625f84b7..b98605f59fcfc 100644 --- a/google/cloud/talent/v4/internal/job_tracing_stub.h +++ b/google/cloud/talent/v4/internal/job_tracing_stub.h @@ -102,6 +102,10 @@ class JobServiceTracingStub : public JobServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::talent::v4::SearchJobsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/talent/v4/internal/tenant_auth_decorator.cc b/google/cloud/talent/v4/internal/tenant_auth_decorator.cc index 6aaa2375ff176..f7e85a83ff224 100644 --- a/google/cloud/talent/v4/internal/tenant_auth_decorator.cc +++ b/google/cloud/talent/v4/internal/tenant_auth_decorator.cc @@ -72,6 +72,14 @@ TenantServiceAuth::ListTenants( return child_->ListTenants(context, options, request); } +StatusOr TenantServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace talent_v4_internal } // namespace cloud diff --git a/google/cloud/talent/v4/internal/tenant_auth_decorator.h b/google/cloud/talent/v4/internal/tenant_auth_decorator.h index 7c4d8d5f58b8a..401e9ba828117 100644 --- a/google/cloud/talent/v4/internal/tenant_auth_decorator.h +++ b/google/cloud/talent/v4/internal/tenant_auth_decorator.h @@ -58,6 +58,10 @@ class TenantServiceAuth : public TenantServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::talent::v4::ListTenantsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/talent/v4/internal/tenant_connection_impl.cc b/google/cloud/talent/v4/internal/tenant_connection_impl.cc index 79950f47a7a05..693039f6a0648 100644 --- a/google/cloud/talent/v4/internal/tenant_connection_impl.cc +++ b/google/cloud/talent/v4/internal/tenant_connection_impl.cc @@ -148,6 +148,20 @@ TenantServiceConnectionImpl::ListTenants( }); } +StatusOr +TenantServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace talent_v4_internal } // namespace cloud diff --git a/google/cloud/talent/v4/internal/tenant_connection_impl.h b/google/cloud/talent/v4/internal/tenant_connection_impl.h index 33ad966cfad3f..37372487a5bd4 100644 --- a/google/cloud/talent/v4/internal/tenant_connection_impl.h +++ b/google/cloud/talent/v4/internal/tenant_connection_impl.h @@ -63,6 +63,9 @@ class TenantServiceConnectionImpl : public talent_v4::TenantServiceConnection { StreamRange ListTenants( google::cloud::talent::v4::ListTenantsRequest request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/talent/v4/internal/tenant_logging_decorator.cc b/google/cloud/talent/v4/internal/tenant_logging_decorator.cc index 5e8419565056e..7113836e2836e 100644 --- a/google/cloud/talent/v4/internal/tenant_logging_decorator.cc +++ b/google/cloud/talent/v4/internal/tenant_logging_decorator.cc @@ -91,6 +91,17 @@ TenantServiceLogging::ListTenants( context, options, request, __func__, tracing_options_); } +StatusOr TenantServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace talent_v4_internal } // namespace cloud diff --git a/google/cloud/talent/v4/internal/tenant_logging_decorator.h b/google/cloud/talent/v4/internal/tenant_logging_decorator.h index 35e51d4a8a838..93256403110e3 100644 --- a/google/cloud/talent/v4/internal/tenant_logging_decorator.h +++ b/google/cloud/talent/v4/internal/tenant_logging_decorator.h @@ -58,6 +58,10 @@ class TenantServiceLogging : public TenantServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::talent::v4::ListTenantsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/talent/v4/internal/tenant_metadata_decorator.cc b/google/cloud/talent/v4/internal/tenant_metadata_decorator.cc index 74ef7da87a9dc..04337cc4922d0 100644 --- a/google/cloud/talent/v4/internal/tenant_metadata_decorator.cc +++ b/google/cloud/talent/v4/internal/tenant_metadata_decorator.cc @@ -86,6 +86,14 @@ TenantServiceMetadata::ListTenants( return child_->ListTenants(context, options, request); } +StatusOr TenantServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + void TenantServiceMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/talent/v4/internal/tenant_metadata_decorator.h b/google/cloud/talent/v4/internal/tenant_metadata_decorator.h index 9c1211ca3eb29..179f040b87f87 100644 --- a/google/cloud/talent/v4/internal/tenant_metadata_decorator.h +++ b/google/cloud/talent/v4/internal/tenant_metadata_decorator.h @@ -58,6 +58,10 @@ class TenantServiceMetadata : public TenantServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::talent::v4::ListTenantsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/talent/v4/internal/tenant_stub.cc b/google/cloud/talent/v4/internal/tenant_stub.cc index 72f4a18058159..bb392ddeaee15 100644 --- a/google/cloud/talent/v4/internal/tenant_stub.cc +++ b/google/cloud/talent/v4/internal/tenant_stub.cc @@ -88,6 +88,17 @@ DefaultTenantServiceStub::ListTenants( return response; } +StatusOr DefaultTenantServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace talent_v4_internal } // namespace cloud diff --git a/google/cloud/talent/v4/internal/tenant_stub.h b/google/cloud/talent/v4/internal/tenant_stub.h index 5992293fbd87e..90c187f796217 100644 --- a/google/cloud/talent/v4/internal/tenant_stub.h +++ b/google/cloud/talent/v4/internal/tenant_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -54,14 +55,21 @@ class TenantServiceStub { virtual StatusOr ListTenants( grpc::ClientContext& context, Options const& options, google::cloud::talent::v4::ListTenantsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; }; class DefaultTenantServiceStub : public TenantServiceStub { public: explicit DefaultTenantServiceStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr CreateTenant( grpc::ClientContext& context, Options const& options, @@ -83,9 +91,15 @@ class DefaultTenantServiceStub : public TenantServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::talent::v4::ListTenantsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/talent/v4/internal/tenant_stub_factory.cc b/google/cloud/talent/v4/internal/tenant_stub_factory.cc index 27444c53aeff4..94edb8bcb0ebf 100644 --- a/google/cloud/talent/v4/internal/tenant_stub_factory.cc +++ b/google/cloud/talent/v4/internal/tenant_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 CreateDefaultTenantServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::talent::v4::TenantService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_stub)); if (auth->RequiresConfigureContext()) { stub = diff --git a/google/cloud/talent/v4/internal/tenant_tracing_connection.cc b/google/cloud/talent/v4/internal/tenant_tracing_connection.cc index 2b0501808d4d0..de0a53aa88e86 100644 --- a/google/cloud/talent/v4/internal/tenant_tracing_connection.cc +++ b/google/cloud/talent/v4/internal/tenant_tracing_connection.cc @@ -79,6 +79,15 @@ TenantServiceTracingConnection::ListTenants( std::move(span), std::move(sr)); } +StatusOr +TenantServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("talent_v4::TenantServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/talent/v4/internal/tenant_tracing_connection.h b/google/cloud/talent/v4/internal/tenant_tracing_connection.h index 5c0c3d2bb1e2f..4000309233b53 100644 --- a/google/cloud/talent/v4/internal/tenant_tracing_connection.h +++ b/google/cloud/talent/v4/internal/tenant_tracing_connection.h @@ -55,6 +55,9 @@ class TenantServiceTracingConnection StreamRange ListTenants( google::cloud::talent::v4::ListTenantsRequest request) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/talent/v4/internal/tenant_tracing_stub.cc b/google/cloud/talent/v4/internal/tenant_tracing_stub.cc index 0105a13f00cbd..45c91e61c5536 100644 --- a/google/cloud/talent/v4/internal/tenant_tracing_stub.cc +++ b/google/cloud/talent/v4/internal/tenant_tracing_stub.cc @@ -90,6 +90,17 @@ TenantServiceTracingStub::ListTenants( child_->ListTenants(context, options, request)); } +StatusOr TenantServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.talent.v4.TenantService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeTenantServiceTracingStub( diff --git a/google/cloud/talent/v4/internal/tenant_tracing_stub.h b/google/cloud/talent/v4/internal/tenant_tracing_stub.h index c42129a43e2f2..a70d4cc8f36f1 100644 --- a/google/cloud/talent/v4/internal/tenant_tracing_stub.h +++ b/google/cloud/talent/v4/internal/tenant_tracing_stub.h @@ -58,6 +58,10 @@ class TenantServiceTracingStub : public TenantServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::talent::v4::ListTenantsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/talent/v4/job_client.cc b/google/cloud/talent/v4/job_client.cc index d1277008d9081..046767e2a3c4f 100644 --- a/google/cloud/talent/v4/job_client.cc +++ b/google/cloud/talent/v4/job_client.cc @@ -252,6 +252,20 @@ JobServiceClient::SearchJobsForAlert( return connection_->SearchJobsForAlert(request); } +StatusOr JobServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr JobServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace talent_v4 } // namespace cloud diff --git a/google/cloud/talent/v4/job_client.h b/google/cloud/talent/v4/job_client.h index db752d6cece7f..0ea59153aa88e 100644 --- a/google/cloud/talent/v4/job_client.h +++ b/google/cloud/talent/v4/job_client.h @@ -881,6 +881,66 @@ class JobServiceClient { google::cloud::talent::v4::SearchJobsRequest const& request, Options opts = {}); + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/talent/v4/job_connection.cc b/google/cloud/talent/v4/job_connection.cc index 9316dd44f9e50..a304f5b95343a 100644 --- a/google/cloud/talent/v4/job_connection.cc +++ b/google/cloud/talent/v4/job_connection.cc @@ -140,6 +140,11 @@ JobServiceConnection::SearchJobsForAlert( return Status(StatusCode::kUnimplemented, "not implemented"); } +StatusOr JobServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeJobServiceConnection( Options options) { internal::CheckExpectedOptions SearchJobsForAlert( google::cloud::talent::v4::SearchJobsRequest const& request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/talent/v4/job_connection_idempotency_policy.cc b/google/cloud/talent/v4/job_connection_idempotency_policy.cc index eacd6c8fbf2dd..386ac3500a115 100644 --- a/google/cloud/talent/v4/job_connection_idempotency_policy.cc +++ b/google/cloud/talent/v4/job_connection_idempotency_policy.cc @@ -84,6 +84,11 @@ Idempotency JobServiceConnectionIdempotencyPolicy::SearchJobsForAlert( return Idempotency::kNonIdempotent; } +Idempotency JobServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultJobServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/talent/v4/job_connection_idempotency_policy.h b/google/cloud/talent/v4/job_connection_idempotency_policy.h index 54c656433c87f..2498f8ee006f8 100644 --- a/google/cloud/talent/v4/job_connection_idempotency_policy.h +++ b/google/cloud/talent/v4/job_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -65,6 +66,9 @@ class JobServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency SearchJobsForAlert( google::cloud::talent::v4::SearchJobsRequest const& request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/talent/v4/mocks/mock_company_connection.h b/google/cloud/talent/v4/mocks/mock_company_connection.h index 0dccf8cccfc2a..06c40ce87fae5 100644 --- a/google/cloud/talent/v4/mocks/mock_company_connection.h +++ b/google/cloud/talent/v4/mocks/mock_company_connection.h @@ -66,6 +66,10 @@ class MockCompanyServiceConnection MOCK_METHOD((StreamRange), ListCompanies, (google::cloud::talent::v4::ListCompaniesRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/talent/v4/mocks/mock_completion_connection.h b/google/cloud/talent/v4/mocks/mock_completion_connection.h index ffebf604ed992..bd4fac5ad4ebc 100644 --- a/google/cloud/talent/v4/mocks/mock_completion_connection.h +++ b/google/cloud/talent/v4/mocks/mock_completion_connection.h @@ -50,6 +50,10 @@ class MockCompletionConnection : public talent_v4::CompletionConnection { CompleteQuery, (google::cloud::talent::v4::CompleteQueryRequest const& request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/talent/v4/mocks/mock_event_connection.h b/google/cloud/talent/v4/mocks/mock_event_connection.h index 73269638c98a1..126386d82e262 100644 --- a/google/cloud/talent/v4/mocks/mock_event_connection.h +++ b/google/cloud/talent/v4/mocks/mock_event_connection.h @@ -50,6 +50,10 @@ class MockEventServiceConnection : public talent_v4::EventServiceConnection { StatusOr, CreateClientEvent, (google::cloud::talent::v4::CreateClientEventRequest const& request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/talent/v4/mocks/mock_job_connection.h b/google/cloud/talent/v4/mocks/mock_job_connection.h index 21b8be10df8ee..bd5bd63b9e35d 100644 --- a/google/cloud/talent/v4/mocks/mock_job_connection.h +++ b/google/cloud/talent/v4/mocks/mock_job_connection.h @@ -194,6 +194,10 @@ class MockJobServiceConnection : public talent_v4::JobServiceConnection { SearchJobsForAlert, (google::cloud::talent::v4::SearchJobsRequest const& request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/talent/v4/mocks/mock_tenant_connection.h b/google/cloud/talent/v4/mocks/mock_tenant_connection.h index 8fef3df968515..0221d761df9b2 100644 --- a/google/cloud/talent/v4/mocks/mock_tenant_connection.h +++ b/google/cloud/talent/v4/mocks/mock_tenant_connection.h @@ -65,6 +65,10 @@ class MockTenantServiceConnection : public talent_v4::TenantServiceConnection { MOCK_METHOD((StreamRange), ListTenants, (google::cloud::talent::v4::ListTenantsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/talent/v4/tenant_client.cc b/google/cloud/talent/v4/tenant_client.cc index b76c7648ed34b..a9dba1b4d1f37 100644 --- a/google/cloud/talent/v4/tenant_client.cc +++ b/google/cloud/talent/v4/tenant_client.cc @@ -109,6 +109,20 @@ StreamRange TenantServiceClient::ListTenants( return connection_->ListTenants(std::move(request)); } +StatusOr TenantServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr TenantServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace talent_v4 } // namespace cloud diff --git a/google/cloud/talent/v4/tenant_client.h b/google/cloud/talent/v4/tenant_client.h index 3dbb75fee2644..401e92e7f122f 100644 --- a/google/cloud/talent/v4/tenant_client.h +++ b/google/cloud/talent/v4/tenant_client.h @@ -402,6 +402,66 @@ class TenantServiceClient { StreamRange ListTenants( google::cloud::talent::v4::ListTenantsRequest request, Options opts = {}); + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/talent/v4/tenant_connection.cc b/google/cloud/talent/v4/tenant_connection.cc index 2ddeddd6bfa8c..471b1862c7e69 100644 --- a/google/cloud/talent/v4/tenant_connection.cc +++ b/google/cloud/talent/v4/tenant_connection.cc @@ -68,6 +68,11 @@ TenantServiceConnection::ListTenants( StreamRange>(); } +StatusOr TenantServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeTenantServiceConnection( Options options) { internal::CheckExpectedOptions ListTenants( google::cloud::talent::v4::ListTenantsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/talent/v4/tenant_connection_idempotency_policy.cc b/google/cloud/talent/v4/tenant_connection_idempotency_policy.cc index 82453c883e2fd..c68cfc602d007 100644 --- a/google/cloud/talent/v4/tenant_connection_idempotency_policy.cc +++ b/google/cloud/talent/v4/tenant_connection_idempotency_policy.cc @@ -59,6 +59,11 @@ Idempotency TenantServiceConnectionIdempotencyPolicy::ListTenants( return Idempotency::kIdempotent; } +Idempotency TenantServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultTenantServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/talent/v4/tenant_connection_idempotency_policy.h b/google/cloud/talent/v4/tenant_connection_idempotency_policy.h index c40e0742447d1..2b319ab3c0a2e 100644 --- a/google/cloud/talent/v4/tenant_connection_idempotency_policy.h +++ b/google/cloud/talent/v4/tenant_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,9 @@ class TenantServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListTenants( google::cloud::talent::v4::ListTenantsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest 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 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..d7e1e127ad115 100644 --- a/google/cloud/tasks/v2/internal/cloud_tasks_stub.h +++ b/google/cloud/tasks/v2/internal/cloud_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 @@ -99,14 +100,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 +185,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..bd1e54a18243d 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,56 @@ 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); +} + +StatusOr +TelcoAutomationAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr TelcoAutomationAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status TelcoAutomationAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status TelcoAutomationAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..460628f125fb3 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..a60c881f4184b 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,127 @@ 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__); +} + +StreamRange +TelcoAutomationConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +TelcoAutomationConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status TelcoAutomationConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status TelcoAutomationConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..aa1d2809d2774 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..d1cbf6290a4ea 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,74 @@ 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_); +} + +StatusOr +TelcoAutomationLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr TelcoAutomationLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status TelcoAutomationLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status TelcoAutomationLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..0892b0f4adb30 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..353454701f5f8 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,57 @@ 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); +} + +StatusOr +TelcoAutomationMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr TelcoAutomationMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status TelcoAutomationMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status TelcoAutomationMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..f7bd774a06192 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..c25f638b614fd 100644 --- a/google/cloud/telcoautomation/v1/internal/telco_automation_stub.cc +++ b/google/cloud/telcoautomation/v1/internal/telco_automation_stub.cc @@ -580,6 +580,76 @@ 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; +} + +StatusOr +DefaultTelcoAutomationStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultTelcoAutomationStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultTelcoAutomationStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultTelcoAutomationStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..6eea109cc19f5 100644 --- a/google/cloud/telcoautomation/v1/internal/telco_automation_stub.h +++ b/google/cloud/telcoautomation/v1/internal/telco_automation_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 @@ -283,6 +284,31 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -302,9 +328,16 @@ class DefaultTelcoAutomationStub : public TelcoAutomationStub { std::unique_ptr< google::cloud::telcoautomation::v1::TelcoAutomation::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr< google::cloud::telcoautomation::v1::ListOrchestrationClustersResponse> @@ -535,6 +568,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -551,6 +608,10 @@ class DefaultTelcoAutomationStub : public TelcoAutomationStub { std::unique_ptr< google::cloud::telcoautomation::v1::TelcoAutomation::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..6269e2b0fff79 100644 --- a/google/cloud/telcoautomation/v1/internal/telco_automation_stub_factory.cc +++ b/google/cloud/telcoautomation/v1/internal/telco_automation_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,14 @@ std::shared_ptr CreateDefaultTelcoAutomationStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::telcoautomation::v1::TelcoAutomation::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..e24692f02b9c7 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,62 @@ 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)); +} + +StreamRange +TelcoAutomationTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "telcoautomation_v1::TelcoAutomationConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +TelcoAutomationTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "telcoautomation_v1::TelcoAutomationConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status TelcoAutomationTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "telcoautomation_v1::TelcoAutomationConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status TelcoAutomationTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "telcoautomation_v1::TelcoAutomationConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..21247b09f36bc 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..dc70da756a8d2 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,76 @@ 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)); +} + +StatusOr +TelcoAutomationTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.telcoautomation.v1.TelcoAutomation", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +TelcoAutomationTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.telcoautomation.v1.TelcoAutomation", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status TelcoAutomationTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.telcoautomation.v1.TelcoAutomation", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status TelcoAutomationTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.telcoautomation.v1.TelcoAutomation", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..3c61f49821850 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..03cb18afffc38 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,29 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..5b1517cab134c 100644 --- a/google/cloud/telcoautomation/v1/telco_automation_client.cc +++ b/google/cloud/telcoautomation/v1/telco_automation_client.cc @@ -781,6 +781,78 @@ 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); +} + +StreamRange +TelcoAutomationClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +TelcoAutomationClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr TelcoAutomationClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr TelcoAutomationClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status TelcoAutomationClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status TelcoAutomationClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status TelcoAutomationClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status TelcoAutomationClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..5cbb4c7fad5a4 100644 --- a/google/cloud/telcoautomation/v1/telco_automation_client.h +++ b/google/cloud/telcoautomation/v1/telco_automation_client.h @@ -2640,6 +2640,356 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..20ef15711c190 100644 --- a/google/cloud/telcoautomation/v1/telco_automation_connection.cc +++ b/google/cloud/telcoautomation/v1/telco_automation_connection.cc @@ -348,6 +348,44 @@ 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"); +} + +StreamRange +TelcoAutomationConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +TelcoAutomationConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status TelcoAutomationConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status TelcoAutomationConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeTelcoAutomationConnection( Options options) { internal::CheckExpectedOptions ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..b8da0cb06ceb3 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,36 @@ 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; +} + +Idempotency TelcoAutomationConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency TelcoAutomationConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency TelcoAutomationConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency TelcoAutomationConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..712c176f3915d 100644 --- a/google/cloud/telcoautomation/v1/telco_automation_connection_idempotency_policy.h +++ b/google/cloud/telcoautomation/v1/telco_automation_connection_idempotency_policy.h @@ -21,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -171,6 +173,24 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/texttospeech/v1/internal/text_to_speech_auth_decorator.cc b/google/cloud/texttospeech/v1/internal/text_to_speech_auth_decorator.cc index 86ae876081753..c2b88730af878 100644 --- a/google/cloud/texttospeech/v1/internal/text_to_speech_auth_decorator.cc +++ b/google/cloud/texttospeech/v1/internal/text_to_speech_auth_decorator.cc @@ -69,6 +69,23 @@ TextToSpeechAuth::AsyncStreamingSynthesize( std::move(context), auth_, StreamAuth::StreamFactory(std::move(call))); } +StatusOr +TextToSpeechAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr TextToSpeechAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace texttospeech_v1_internal } // namespace cloud diff --git a/google/cloud/texttospeech/v1/internal/text_to_speech_auth_decorator.h b/google/cloud/texttospeech/v1/internal/text_to_speech_auth_decorator.h index 4caf7ee760ebb..4c6923c587ba6 100644 --- a/google/cloud/texttospeech/v1/internal/text_to_speech_auth_decorator.h +++ b/google/cloud/texttospeech/v1/internal/text_to_speech_auth_decorator.h @@ -57,6 +57,14 @@ class TextToSpeechAuth : public TextToSpeechStub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/texttospeech/v1/internal/text_to_speech_connection_impl.cc b/google/cloud/texttospeech/v1/internal/text_to_speech_connection_impl.cc index bc92d687c9390..17c8514c4cc5c 100644 --- a/google/cloud/texttospeech/v1/internal/text_to_speech_connection_impl.cc +++ b/google/cloud/texttospeech/v1/internal/text_to_speech_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,53 @@ TextToSpeechConnectionImpl::AsyncStreamingSynthesize() { internal::SaveCurrentOptions()); } +StreamRange +TextToSpeechConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +TextToSpeechConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace texttospeech_v1_internal } // namespace cloud diff --git a/google/cloud/texttospeech/v1/internal/text_to_speech_connection_impl.h b/google/cloud/texttospeech/v1/internal/text_to_speech_connection_impl.h index 25fe16a643ad5..691f3aa8e1e0a 100644 --- a/google/cloud/texttospeech/v1/internal/text_to_speech_connection_impl.h +++ b/google/cloud/texttospeech/v1/internal/text_to_speech_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 @@ -63,6 +64,12 @@ class TextToSpeechConnectionImpl google::cloud::texttospeech::v1::StreamingSynthesizeResponse>> AsyncStreamingSynthesize() override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/texttospeech/v1/internal/text_to_speech_logging_decorator.cc b/google/cloud/texttospeech/v1/internal/text_to_speech_logging_decorator.cc index 1f8dd908c6f0d..589b6f78db9c5 100644 --- a/google/cloud/texttospeech/v1/internal/text_to_speech_logging_decorator.cc +++ b/google/cloud/texttospeech/v1/internal/text_to_speech_logging_decorator.cc @@ -87,6 +87,29 @@ TextToSpeechLogging::AsyncStreamingSynthesize( return stream; } +StatusOr +TextToSpeechLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr TextToSpeechLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace texttospeech_v1_internal } // namespace cloud diff --git a/google/cloud/texttospeech/v1/internal/text_to_speech_logging_decorator.h b/google/cloud/texttospeech/v1/internal/text_to_speech_logging_decorator.h index ad02143e047c6..88c8d7960540d 100644 --- a/google/cloud/texttospeech/v1/internal/text_to_speech_logging_decorator.h +++ b/google/cloud/texttospeech/v1/internal/text_to_speech_logging_decorator.h @@ -57,6 +57,14 @@ class TextToSpeechLogging : public TextToSpeechStub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/texttospeech/v1/internal/text_to_speech_metadata_decorator.cc b/google/cloud/texttospeech/v1/internal/text_to_speech_metadata_decorator.cc index ab610c010c520..6207b7735cd2b 100644 --- a/google/cloud/texttospeech/v1/internal/text_to_speech_metadata_decorator.cc +++ b/google/cloud/texttospeech/v1/internal/text_to_speech_metadata_decorator.cc @@ -72,6 +72,23 @@ TextToSpeechMetadata::AsyncStreamingSynthesize( std::move(options)); } +StatusOr +TextToSpeechMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr TextToSpeechMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + void TextToSpeechMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/texttospeech/v1/internal/text_to_speech_metadata_decorator.h b/google/cloud/texttospeech/v1/internal/text_to_speech_metadata_decorator.h index 1a51942145c18..383518e041099 100644 --- a/google/cloud/texttospeech/v1/internal/text_to_speech_metadata_decorator.h +++ b/google/cloud/texttospeech/v1/internal/text_to_speech_metadata_decorator.h @@ -57,6 +57,14 @@ class TextToSpeechMetadata : public TextToSpeechStub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/texttospeech/v1/internal/text_to_speech_stub.cc b/google/cloud/texttospeech/v1/internal/text_to_speech_stub.cc index dada28e6f170c..3cb7412ef4be2 100644 --- a/google/cloud/texttospeech/v1/internal/text_to_speech_stub.cc +++ b/google/cloud/texttospeech/v1/internal/text_to_speech_stub.cc @@ -71,6 +71,29 @@ DefaultTextToSpeechStub::AsyncStreamingSynthesize( }); } +StatusOr +DefaultTextToSpeechStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultTextToSpeechStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace texttospeech_v1_internal } // namespace cloud diff --git a/google/cloud/texttospeech/v1/internal/text_to_speech_stub.h b/google/cloud/texttospeech/v1/internal/text_to_speech_stub.h index 26df42472d437..d18599cfc12a9 100644 --- a/google/cloud/texttospeech/v1/internal/text_to_speech_stub.h +++ b/google/cloud/texttospeech/v1/internal/text_to_speech_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -55,6 +56,14 @@ class TextToSpeechStub { google::cloud::CompletionQueue const& cq, std::shared_ptr context, google::cloud::internal::ImmutableOptions options) = 0; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; }; class DefaultTextToSpeechStub : public TextToSpeechStub { @@ -62,8 +71,11 @@ class DefaultTextToSpeechStub : public TextToSpeechStub { explicit DefaultTextToSpeechStub( std::unique_ptr< google::cloud::texttospeech::v1::TextToSpeech::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} StatusOr ListVoices( grpc::ClientContext& context, Options const& options, @@ -84,9 +96,19 @@ class DefaultTextToSpeechStub : public TextToSpeechStub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/texttospeech/v1/internal/text_to_speech_stub_factory.cc b/google/cloud/texttospeech/v1/internal/text_to_speech_stub_factory.cc index 29383e4eb67cb..3317a73025a3f 100644 --- a/google/cloud/texttospeech/v1/internal/text_to_speech_stub_factory.cc +++ b/google/cloud/texttospeech/v1/internal/text_to_speech_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 CreateDefaultTextToSpeechStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::texttospeech::v1::TextToSpeech::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), std::move(stub)); diff --git a/google/cloud/texttospeech/v1/internal/text_to_speech_tracing_connection.cc b/google/cloud/texttospeech/v1/internal/text_to_speech_tracing_connection.cc index 51a8beb634496..a56f96b2c7a09 100644 --- a/google/cloud/texttospeech/v1/internal/text_to_speech_tracing_connection.cc +++ b/google/cloud/texttospeech/v1/internal/text_to_speech_tracing_connection.cc @@ -18,6 +18,7 @@ #include "google/cloud/texttospeech/v1/internal/text_to_speech_tracing_connection.h" #include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" #include #include @@ -57,6 +58,26 @@ TextToSpeechTracingConnection::AsyncStreamingSynthesize() { return child_->AsyncStreamingSynthesize(); } +StreamRange +TextToSpeechTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "texttospeech_v1::TextToSpeechConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +TextToSpeechTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "texttospeech_v1::TextToSpeechConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/texttospeech/v1/internal/text_to_speech_tracing_connection.h b/google/cloud/texttospeech/v1/internal/text_to_speech_tracing_connection.h index 69a6fde27309b..4ce81470d193d 100644 --- a/google/cloud/texttospeech/v1/internal/text_to_speech_tracing_connection.h +++ b/google/cloud/texttospeech/v1/internal/text_to_speech_tracing_connection.h @@ -54,6 +54,12 @@ class TextToSpeechTracingConnection google::cloud::texttospeech::v1::StreamingSynthesizeResponse>> AsyncStreamingSynthesize() override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/texttospeech/v1/internal/text_to_speech_tracing_stub.cc b/google/cloud/texttospeech/v1/internal/text_to_speech_tracing_stub.cc index 23456c08a5d29..7eb555f5f322f 100644 --- a/google/cloud/texttospeech/v1/internal/text_to_speech_tracing_stub.cc +++ b/google/cloud/texttospeech/v1/internal/text_to_speech_tracing_stub.cc @@ -75,6 +75,29 @@ TextToSpeechTracingStub::AsyncStreamingSynthesize( std::move(context), std::move(stream), std::move(span)); } +StatusOr +TextToSpeechTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.texttospeech.v1.TextToSpeech", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr TextToSpeechTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.texttospeech.v1.TextToSpeech", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeTextToSpeechTracingStub( diff --git a/google/cloud/texttospeech/v1/internal/text_to_speech_tracing_stub.h b/google/cloud/texttospeech/v1/internal/text_to_speech_tracing_stub.h index ba7d00ddeb7b7..9990f8fd8e390 100644 --- a/google/cloud/texttospeech/v1/internal/text_to_speech_tracing_stub.h +++ b/google/cloud/texttospeech/v1/internal/text_to_speech_tracing_stub.h @@ -57,6 +57,14 @@ class TextToSpeechTracingStub : public TextToSpeechStub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/texttospeech/v1/mocks/mock_text_to_speech_connection.h b/google/cloud/texttospeech/v1/mocks/mock_text_to_speech_connection.h index d8b7e9c28472f..ecdd9f29a35ae 100644 --- a/google/cloud/texttospeech/v1/mocks/mock_text_to_speech_connection.h +++ b/google/cloud/texttospeech/v1/mocks/mock_text_to_speech_connection.h @@ -63,6 +63,13 @@ class MockTextToSpeechConnection google::cloud::texttospeech::v1::StreamingSynthesizeRequest, google::cloud::texttospeech::v1::StreamingSynthesizeResponse>>), AsyncStreamingSynthesize, (), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/texttospeech/v1/text_to_speech_client.cc b/google/cloud/texttospeech/v1/text_to_speech_client.cc index dfa1b21f91366..98a8b70900e77 100644 --- a/google/cloud/texttospeech/v1/text_to_speech_client.cc +++ b/google/cloud/texttospeech/v1/text_to_speech_client.cc @@ -78,6 +78,35 @@ TextToSpeechClient::AsyncStreamingSynthesize(Options opts) { return connection_->AsyncStreamingSynthesize(); } +StreamRange TextToSpeechClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange TextToSpeechClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr TextToSpeechClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr TextToSpeechClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace texttospeech_v1 } // namespace cloud diff --git a/google/cloud/texttospeech/v1/text_to_speech_client.h b/google/cloud/texttospeech/v1/text_to_speech_client.h index 0d61fd0bf77a6..942daefb41e30 100644 --- a/google/cloud/texttospeech/v1/text_to_speech_client.h +++ b/google/cloud/texttospeech/v1/text_to_speech_client.h @@ -244,6 +244,158 @@ class TextToSpeechClient { google::cloud::texttospeech::v1::StreamingSynthesizeResponse>> AsyncStreamingSynthesize(Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/texttospeech/v1/text_to_speech_connection.cc b/google/cloud/texttospeech/v1/text_to_speech_connection.cc index 6e97395bc93b3..6dcad5490c00f 100644 --- a/google/cloud/texttospeech/v1/text_to_speech_connection.cc +++ b/google/cloud/texttospeech/v1/text_to_speech_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 @@ -60,6 +61,19 @@ TextToSpeechConnection::AsyncStreamingSynthesize() { Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +TextToSpeechConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr TextToSpeechConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeTextToSpeechConnection( Options options) { internal::CheckExpectedOptions #include @@ -193,6 +194,12 @@ class TextToSpeechConnection { google::cloud::texttospeech::v1::StreamingSynthesizeRequest, google::cloud::texttospeech::v1::StreamingSynthesizeResponse>> AsyncStreamingSynthesize(); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/texttospeech/v1/text_to_speech_connection_idempotency_policy.cc b/google/cloud/texttospeech/v1/text_to_speech_connection_idempotency_policy.cc index a496d5022071c..3d70dcaf75ef5 100644 --- a/google/cloud/texttospeech/v1/text_to_speech_connection_idempotency_policy.cc +++ b/google/cloud/texttospeech/v1/text_to_speech_connection_idempotency_policy.cc @@ -44,6 +44,16 @@ Idempotency TextToSpeechConnectionIdempotencyPolicy::SynthesizeSpeech( return Idempotency::kNonIdempotent; } +Idempotency TextToSpeechConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency TextToSpeechConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultTextToSpeechConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/texttospeech/v1/text_to_speech_connection_idempotency_policy.h b/google/cloud/texttospeech/v1/text_to_speech_connection_idempotency_policy.h index fef0b18d044ee..f644468547c1d 100644 --- a/google/cloud/texttospeech/v1/text_to_speech_connection_idempotency_policy.h +++ b/google/cloud/texttospeech/v1/text_to_speech_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 TextToSpeechConnectionIdempotencyPolicy { virtual google::cloud::Idempotency SynthesizeSpeech( google::cloud::texttospeech::v1::SynthesizeSpeechRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest 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/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..050a10b55c232 100644 --- a/google/cloud/tpu/v1/internal/tpu_auth_decorator.cc +++ b/google/cloud/tpu/v1/internal/tpu_auth_decorator.cc @@ -217,6 +217,54 @@ 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); +} + +StatusOr TpuAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr TpuAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status TpuAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status TpuAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..0ea687762ea28 100644 --- a/google/cloud/tpu/v1/internal/tpu_auth_decorator.h +++ b/google/cloud/tpu/v1/internal/tpu_auth_decorator.h @@ -119,6 +119,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..f899a15976754 100644 --- a/google/cloud/tpu/v1/internal/tpu_connection_impl.cc +++ b/google/cloud/tpu/v1/internal/tpu_connection_impl.cc @@ -624,6 +624,121 @@ 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__); +} + +StreamRange TpuConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr TpuConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status TpuConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status TpuConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..55e228bdbf300 100644 --- a/google/cloud/tpu/v1/internal/tpu_connection_impl.h +++ b/google/cloud/tpu/v1/internal/tpu_connection_impl.h @@ -120,6 +120,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..aa0db4525fec9 100644 --- a/google/cloud/tpu/v1/internal/tpu_logging_decorator.cc +++ b/google/cloud/tpu/v1/internal/tpu_logging_decorator.cc @@ -248,6 +248,74 @@ 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_); +} + +StatusOr +TpuLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr TpuLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status TpuLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status TpuLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..63423196a070f 100644 --- a/google/cloud/tpu/v1/internal/tpu_logging_decorator.h +++ b/google/cloud/tpu/v1/internal/tpu_logging_decorator.h @@ -118,6 +118,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..766b049e865ae 100644 --- a/google/cloud/tpu/v1/internal/tpu_metadata_decorator.cc +++ b/google/cloud/tpu/v1/internal/tpu_metadata_decorator.cc @@ -190,6 +190,56 @@ 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); +} + +StatusOr +TpuMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr TpuMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status TpuMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status TpuMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..d965b3af2d954 100644 --- a/google/cloud/tpu/v1/internal/tpu_metadata_decorator.h +++ b/google/cloud/tpu/v1/internal/tpu_metadata_decorator.h @@ -119,6 +119,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..e52e949dad0ec 100644 --- a/google/cloud/tpu/v1/internal/tpu_stub.cc +++ b/google/cloud/tpu/v1/internal/tpu_stub.cc @@ -240,6 +240,74 @@ 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; +} + +StatusOr +DefaultTpuStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultTpuStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultTpuStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultTpuStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..5b908428b9de0 100644 --- a/google/cloud/tpu/v1/internal/tpu_stub.h +++ b/google/cloud/tpu/v1/internal/tpu_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 @@ -115,6 +116,31 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -132,9 +158,16 @@ class DefaultTpuStub : public TpuStub { public: DefaultTpuStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListNodes( grpc::ClientContext& context, Options const& options, @@ -216,6 +249,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -230,6 +287,10 @@ class DefaultTpuStub : public TpuStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..a01bcacbeea88 100644 --- a/google/cloud/tpu/v1/internal/tpu_stub_factory.cc +++ b/google/cloud/tpu/v1/internal/tpu_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 @@ -43,8 +45,13 @@ 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_operations_stub = + google::longrunning::Operations::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_operations_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..2f1e3b7018090 100644 --- a/google/cloud/tpu/v1/internal/tpu_tracing_connection.cc +++ b/google/cloud/tpu/v1/internal/tpu_tracing_connection.cc @@ -194,6 +194,54 @@ 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)); +} + +StreamRange +TpuTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan("tpu_v1::TpuConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr TpuTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan("tpu_v1::TpuConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status TpuTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan("tpu_v1::TpuConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status TpuTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan("tpu_v1::TpuConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..050f0e07af44a 100644 --- a/google/cloud/tpu/v1/internal/tpu_tracing_connection.h +++ b/google/cloud/tpu/v1/internal/tpu_tracing_connection.h @@ -108,6 +108,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..87ee004d132b9 100644 --- a/google/cloud/tpu/v1/internal/tpu_tracing_stub.cc +++ b/google/cloud/tpu/v1/internal/tpu_tracing_stub.cc @@ -213,6 +213,72 @@ 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)); +} + +StatusOr +TpuTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.tpu.v1.Tpu", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr TpuTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.tpu.v1.Tpu", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status TpuTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.tpu.v1.Tpu", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status TpuTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.tpu.v1.Tpu", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..a5d4978e1ccd2 100644 --- a/google/cloud/tpu/v1/internal/tpu_tracing_stub.h +++ b/google/cloud/tpu/v1/internal/tpu_tracing_stub.h @@ -118,6 +118,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..10b39e352e7e1 100644 --- a/google/cloud/tpu/v1/mocks/mock_tpu_connection.h +++ b/google/cloud/tpu/v1/mocks/mock_tpu_connection.h @@ -243,6 +243,29 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..6ee0868cf1a6c 100644 --- a/google/cloud/tpu/v1/tpu_client.cc +++ b/google/cloud/tpu/v1/tpu_client.cc @@ -255,6 +255,73 @@ 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); +} + +StreamRange TpuClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange TpuClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr TpuClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr TpuClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status TpuClient::DeleteOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status TpuClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status TpuClient::CancelOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status TpuClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..5698fb4f13aba 100644 --- a/google/cloud/tpu/v1/tpu_client.h +++ b/google/cloud/tpu/v1/tpu_client.h @@ -899,6 +899,356 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..77f340648c6be 100644 --- a/google/cloud/tpu/v1/tpu_connection.cc +++ b/google/cloud/tpu/v1/tpu_connection.cc @@ -178,6 +178,40 @@ 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"); +} + +StreamRange TpuConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr TpuConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status TpuConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status TpuConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeTpuConnection(Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..a0513240630d1 100644 --- a/google/cloud/tpu/v1/tpu_connection_idempotency_policy.cc +++ b/google/cloud/tpu/v1/tpu_connection_idempotency_policy.cc @@ -88,6 +88,36 @@ 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; +} + +Idempotency TpuConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency TpuConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency TpuConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency TpuConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..ca1c169c0c5f3 100644 --- a/google/cloud/tpu/v1/tpu_connection_idempotency_policy.h +++ b/google/cloud/tpu/v1/tpu_connection_idempotency_policy.h @@ -21,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -68,6 +70,24 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..708e9f9eb72a9 100644 --- a/google/cloud/tpu/v2/internal/tpu_auth_decorator.cc +++ b/google/cloud/tpu/v2/internal/tpu_auth_decorator.cc @@ -234,6 +234,54 @@ 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); +} + +StatusOr TpuAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr TpuAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status TpuAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status TpuAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..5572948c7e054 100644 --- a/google/cloud/tpu/v2/internal/tpu_auth_decorator.h +++ b/google/cloud/tpu/v2/internal/tpu_auth_decorator.h @@ -128,6 +128,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..b2fbdce25251b 100644 --- a/google/cloud/tpu/v2/internal/tpu_connection_impl.cc +++ b/google/cloud/tpu/v2/internal/tpu_connection_impl.cc @@ -652,6 +652,121 @@ 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__); +} + +StreamRange TpuConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr TpuConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status TpuConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status TpuConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..14fc0757e1dc0 100644 --- a/google/cloud/tpu/v2/internal/tpu_connection_impl.h +++ b/google/cloud/tpu/v2/internal/tpu_connection_impl.h @@ -128,6 +128,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..5b74060b17245 100644 --- a/google/cloud/tpu/v2/internal/tpu_logging_decorator.cc +++ b/google/cloud/tpu/v2/internal/tpu_logging_decorator.cc @@ -271,6 +271,74 @@ 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_); +} + +StatusOr +TpuLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr TpuLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status TpuLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status TpuLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..32395a30c97fc 100644 --- a/google/cloud/tpu/v2/internal/tpu_logging_decorator.h +++ b/google/cloud/tpu/v2/internal/tpu_logging_decorator.h @@ -127,6 +127,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..017bd812e1473 100644 --- a/google/cloud/tpu/v2/internal/tpu_metadata_decorator.cc +++ b/google/cloud/tpu/v2/internal/tpu_metadata_decorator.cc @@ -209,6 +209,56 @@ 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); +} + +StatusOr +TpuMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr TpuMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status TpuMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status TpuMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..e6ec190a8dbad 100644 --- a/google/cloud/tpu/v2/internal/tpu_metadata_decorator.h +++ b/google/cloud/tpu/v2/internal/tpu_metadata_decorator.h @@ -128,6 +128,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..d3b0aa69cb5c7 100644 --- a/google/cloud/tpu/v2/internal/tpu_stub.cc +++ b/google/cloud/tpu/v2/internal/tpu_stub.cc @@ -264,6 +264,74 @@ 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; +} + +StatusOr +DefaultTpuStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultTpuStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultTpuStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultTpuStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..292e3b66d1553 100644 --- a/google/cloud/tpu/v2/internal/tpu_stub.h +++ b/google/cloud/tpu/v2/internal/tpu_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 @@ -125,6 +126,31 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -142,9 +168,16 @@ class DefaultTpuStub : public TpuStub { public: DefaultTpuStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListNodes( grpc::ClientContext& context, Options const& options, @@ -235,6 +268,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -249,6 +306,10 @@ class DefaultTpuStub : public TpuStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..7b48844c3d5a3 100644 --- a/google/cloud/tpu/v2/internal/tpu_stub_factory.cc +++ b/google/cloud/tpu/v2/internal/tpu_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 @@ -43,8 +45,13 @@ 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_operations_stub = + google::longrunning::Operations::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_operations_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..65a51db9e787b 100644 --- a/google/cloud/tpu/v2/internal/tpu_tracing_connection.cc +++ b/google/cloud/tpu/v2/internal/tpu_tracing_connection.cc @@ -209,6 +209,54 @@ 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)); +} + +StreamRange +TpuTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan("tpu_v2::TpuConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr TpuTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan("tpu_v2::TpuConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status TpuTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan("tpu_v2::TpuConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status TpuTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan("tpu_v2::TpuConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..dbe4b853b6e59 100644 --- a/google/cloud/tpu/v2/internal/tpu_tracing_connection.h +++ b/google/cloud/tpu/v2/internal/tpu_tracing_connection.h @@ -116,6 +116,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..70d7bac42da4f 100644 --- a/google/cloud/tpu/v2/internal/tpu_tracing_stub.cc +++ b/google/cloud/tpu/v2/internal/tpu_tracing_stub.cc @@ -237,6 +237,72 @@ 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)); +} + +StatusOr +TpuTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.tpu.v2.Tpu", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr TpuTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.tpu.v2.Tpu", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status TpuTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.tpu.v2.Tpu", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status TpuTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.tpu.v2.Tpu", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..361a2f67b06d9 100644 --- a/google/cloud/tpu/v2/internal/tpu_tracing_stub.h +++ b/google/cloud/tpu/v2/internal/tpu_tracing_stub.h @@ -127,6 +127,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..f1775436635bc 100644 --- a/google/cloud/tpu/v2/mocks/mock_tpu_connection.h +++ b/google/cloud/tpu/v2/mocks/mock_tpu_connection.h @@ -256,6 +256,29 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..9001754bc8576 100644 --- a/google/cloud/tpu/v2/tpu_client.cc +++ b/google/cloud/tpu/v2/tpu_client.cc @@ -291,6 +291,73 @@ 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); +} + +StreamRange TpuClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange TpuClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr TpuClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr TpuClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status TpuClient::DeleteOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status TpuClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status TpuClient::CancelOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status TpuClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..9e3522a69c16c 100644 --- a/google/cloud/tpu/v2/tpu_client.h +++ b/google/cloud/tpu/v2/tpu_client.h @@ -1014,6 +1014,356 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..e7b3a17deb081 100644 --- a/google/cloud/tpu/v2/tpu_connection.cc +++ b/google/cloud/tpu/v2/tpu_connection.cc @@ -190,6 +190,40 @@ 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"); +} + +StreamRange TpuConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr TpuConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status TpuConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status TpuConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeTpuConnection(Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..bf536ca0d9bea 100644 --- a/google/cloud/tpu/v2/tpu_connection_idempotency_policy.cc +++ b/google/cloud/tpu/v2/tpu_connection_idempotency_policy.cc @@ -98,6 +98,36 @@ 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; +} + +Idempotency TpuConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency TpuConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency TpuConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency TpuConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..45b5739cb3b2a 100644 --- a/google/cloud/tpu/v2/tpu_connection_idempotency_policy.h +++ b/google/cloud/tpu/v2/tpu_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,24 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..df2ac7447f32e 100644 --- a/google/cloud/translate/v3/internal/translation_auth_decorator.cc +++ b/google/cloud/translate/v3/internal/translation_auth_decorator.cc @@ -591,6 +591,64 @@ 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); +} + +StatusOr +TranslationServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr TranslationServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status TranslationServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status TranslationServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +StatusOr TranslationServiceAuth::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->WaitOperation(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..9504511aa2aab 100644 --- a/google/cloud/translate/v3/internal/translation_auth_decorator.h +++ b/google/cloud/translate/v3/internal/translation_auth_decorator.h @@ -315,6 +315,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..6c742a1a08b59 100644 --- a/google/cloud/translate/v3/internal/translation_connection_impl.cc +++ b/google/cloud/translate/v3/internal/translation_connection_impl.cc @@ -1656,6 +1656,141 @@ 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__); +} + +StreamRange +TranslationServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +TranslationServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status TranslationServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status TranslationServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +TranslationServiceConnectionImpl::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->WaitOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return stub_->WaitOperation(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..b359ee0d56d5d 100644 --- a/google/cloud/translate/v3/internal/translation_connection_impl.h +++ b/google/cloud/translate/v3/internal/translation_connection_impl.h @@ -300,6 +300,27 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..06145cc6a7394 100644 --- a/google/cloud/translate/v3/internal/translation_logging_decorator.cc +++ b/google/cloud/translate/v3/internal/translation_logging_decorator.cc @@ -740,6 +740,88 @@ 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_); +} + +StatusOr +TranslationServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +TranslationServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status TranslationServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status TranslationServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +TranslationServiceLogging::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + return child_->WaitOperation(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..af943aea25d7d 100644 --- a/google/cloud/translate/v3/internal/translation_logging_decorator.h +++ b/google/cloud/translate/v3/internal/translation_logging_decorator.h @@ -315,6 +315,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..6c63c29b22e32 100644 --- a/google/cloud/translate/v3/internal/translation_metadata_decorator.cc +++ b/google/cloud/translate/v3/internal/translation_metadata_decorator.cc @@ -527,6 +527,66 @@ 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); +} + +StatusOr +TranslationServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +TranslationServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status TranslationServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status TranslationServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +StatusOr +TranslationServiceMetadata::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + SetMetadata(context, options); + return child_->WaitOperation(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..bb6765e84e444 100644 --- a/google/cloud/translate/v3/internal/translation_metadata_decorator.h +++ b/google/cloud/translate/v3/internal/translation_metadata_decorator.h @@ -316,6 +316,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..c935eef3a11dc 100644 --- a/google/cloud/translate/v3/internal/translation_stub.cc +++ b/google/cloud/translate/v3/internal/translation_stub.cc @@ -705,6 +705,88 @@ 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; +} + +StatusOr +DefaultTranslationServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultTranslationServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultTranslationServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultTranslationServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultTranslationServiceStub::WaitOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::WaitOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->WaitOperation(&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..d08b26ae48de9 100644 --- a/google/cloud/translate/v3/internal/translation_stub.h +++ b/google/cloud/translate/v3/internal/translation_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 @@ -302,6 +303,35 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + + virtual StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -321,9 +351,16 @@ class DefaultTranslationServiceStub : public TranslationServiceStub { std::unique_ptr< google::cloud::translation::v3::TranslationService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr TranslateText( grpc::ClientContext& context, Options const& options, @@ -601,6 +638,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -617,6 +682,10 @@ class DefaultTranslationServiceStub : public TranslationServiceStub { std::unique_ptr< google::cloud::translation::v3::TranslationService::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..e038c59362b84 100644 --- a/google/cloud/translate/v3/internal/translation_stub_factory.cc +++ b/google/cloud/translate/v3/internal/translation_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,14 @@ std::shared_ptr CreateDefaultTranslationServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::translation::v3::TranslationService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..60b2bc026667c 100644 --- a/google/cloud/translate/v3/internal/translation_tracing_connection.cc +++ b/google/cloud/translate/v3/internal/translation_tracing_connection.cc @@ -618,6 +618,71 @@ 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)); +} + +StreamRange +TranslationServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "translate_v3::TranslationServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +TranslationServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "translate_v3::TranslationServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status TranslationServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "translate_v3::TranslationServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status TranslationServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "translate_v3::TranslationServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +StatusOr +TranslationServiceTracingConnection::WaitOperation( + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpan( + "translate_v3::TranslationServiceConnection::WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->WaitOperation(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..dd0d1fff38fa0 100644 --- a/google/cloud/translate/v3/internal/translation_tracing_connection.h +++ b/google/cloud/translate/v3/internal/translation_tracing_connection.h @@ -288,6 +288,27 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..15a512b2d569d 100644 --- a/google/cloud/translate/v3/internal/translation_tracing_stub.cc +++ b/google/cloud/translate/v3/internal/translation_tracing_stub.cc @@ -666,6 +666,88 @@ 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)); +} + +StatusOr +TranslationServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.translation.v3.TranslationService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +TranslationServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.translation.v3.TranslationService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status TranslationServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.translation.v3.TranslationService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status TranslationServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.translation.v3.TranslationService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +StatusOr +TranslationServiceTracingStub::WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.translation.v3.TranslationService", "WaitOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->WaitOperation(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..0d42aa22cb63e 100644 --- a/google/cloud/translate/v3/internal/translation_tracing_stub.h +++ b/google/cloud/translate/v3/internal/translation_tracing_stub.h @@ -315,6 +315,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + StatusOr WaitOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::WaitOperationRequest 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..c070e737c874f 100644 --- a/google/cloud/translate/v3/mocks/mock_translation_connection.h +++ b/google/cloud/translate/v3/mocks/mock_translation_connection.h @@ -641,6 +641,33 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, WaitOperation, + (google::longrunning::WaitOperationRequest 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..4b628a3beab78 100644 --- a/google/cloud/translate/v3/translation_client.cc +++ b/google/cloud/translate/v3/translation_client.cc @@ -1001,6 +1001,87 @@ 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); +} + +StreamRange +TranslationServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +TranslationServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr TranslationServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr TranslationServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status TranslationServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status TranslationServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status TranslationServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status TranslationServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +StatusOr +TranslationServiceClient::WaitOperation( + google::longrunning::WaitOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->WaitOperation(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..1eb175e0891ae 100644 --- a/google/cloud/translate/v3/translation_client.h +++ b/google/cloud/translate/v3/translation_client.h @@ -3205,6 +3205,395 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Waits until the specified long-running operation is done or reaches at most + /// a specified timeout, returning the latest state. If the operation is + /// already done, the latest state is immediately returned. If the timeout + /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + /// timeout is used. If the server does not support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// Note that this method is on a best-effort basis. It may return the latest + /// state before the specified timeout (including immediately), meaning even an + /// immediate response is no guarantee that the operation is done. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.WaitOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// [google.longrunning.WaitOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L207} + /// + // clang-format on + StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..9f3c6988785fe 100644 --- a/google/cloud/translate/v3/translation_connection.cc +++ b/google/cloud/translate/v3/translation_connection.cc @@ -468,6 +468,50 @@ 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"); +} + +StreamRange +TranslationServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +TranslationServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status TranslationServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status TranslationServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +TranslationServiceConnection::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeTranslationServiceConnection( Options options) { internal::CheckExpectedOptions> DeleteModel(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual StatusOr WaitOperation( + google::longrunning::WaitOperationRequest 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..4e6cc9fc5dc51 100644 --- a/google/cloud/translate/v3/translation_connection_idempotency_policy.cc +++ b/google/cloud/translate/v3/translation_connection_idempotency_policy.cc @@ -230,6 +230,41 @@ 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; +} + +Idempotency TranslationServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency TranslationServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency TranslationServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency TranslationServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency TranslationServiceConnectionIdempotencyPolicy::WaitOperation( + google::longrunning::WaitOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..0b0c3d499fe1d 100644 --- a/google/cloud/translate/v3/translation_connection_idempotency_policy.h +++ b/google/cloud/translate/v3/translation_connection_idempotency_policy.h @@ -21,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -161,6 +163,27 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); + + virtual google::cloud::Idempotency WaitOperation( + google::longrunning::WaitOperationRequest 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..e1aab863dd79e 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,56 @@ 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); +} + +StatusOr +LivestreamServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr LivestreamServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status LivestreamServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status LivestreamServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..fdc28c7b55ffb 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..f9f257a66cb64 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,129 @@ 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__); +} + +StreamRange +LivestreamServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +LivestreamServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status LivestreamServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status LivestreamServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..c70574c2aea52 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..cecdcff63ea31 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,75 @@ 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_); +} + +StatusOr +LivestreamServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr LivestreamServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status LivestreamServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status LivestreamServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..9a9805bc6d6e5 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..89d5b46dcfd49 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,58 @@ 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); +} + +StatusOr +LivestreamServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +LivestreamServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status LivestreamServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status LivestreamServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..82fdf132d7405 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..850801dfeb67f 100644 --- a/google/cloud/video/livestream/v1/internal/livestream_stub.cc +++ b/google/cloud/video/livestream/v1/internal/livestream_stub.cc @@ -589,6 +589,76 @@ 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; +} + +StatusOr +DefaultLivestreamServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultLivestreamServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultLivestreamServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultLivestreamServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..b46b422604f54 100644 --- a/google/cloud/video/livestream/v1/internal/livestream_stub.h +++ b/google/cloud/video/livestream/v1/internal/livestream_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 @@ -254,6 +255,31 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -273,9 +299,16 @@ class DefaultLivestreamServiceStub : public LivestreamServiceStub { std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateChannel( google::cloud::CompletionQueue& cq, @@ -498,6 +531,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -514,6 +571,10 @@ class DefaultLivestreamServiceStub : public LivestreamServiceStub { std::unique_ptr< google::cloud::video::livestream::v1::LivestreamService::StubInterface> grpc_stub_; + std::unique_ptr + operations_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..b6807d6deae38 100644 --- a/google/cloud/video/livestream/v1/internal/livestream_stub_factory.cc +++ b/google/cloud/video/livestream/v1/internal/livestream_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,14 @@ std::shared_ptr CreateDefaultLivestreamServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::video::livestream::v1::LivestreamService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..33b4ba2778620 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,62 @@ 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)); +} + +StreamRange +LivestreamServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "video_livestream_v1::LivestreamServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +LivestreamServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "video_livestream_v1::LivestreamServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status LivestreamServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "video_livestream_v1::LivestreamServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status LivestreamServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "video_livestream_v1::LivestreamServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..7ed9b19fa2d5e 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..a233f2715f761 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,76 @@ 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)); +} + +StatusOr +LivestreamServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.video.livestream.v1.LivestreamService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +LivestreamServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.video.livestream.v1.LivestreamService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status LivestreamServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.video.livestream.v1.LivestreamService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status LivestreamServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.video.livestream.v1.LivestreamService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..baa81a0e8a06c 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..9efba3586feec 100644 --- a/google/cloud/video/livestream/v1/livestream_client.cc +++ b/google/cloud/video/livestream/v1/livestream_client.cc @@ -802,6 +802,80 @@ 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); +} + +StreamRange +LivestreamServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +LivestreamServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr LivestreamServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr LivestreamServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status LivestreamServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status LivestreamServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status LivestreamServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status LivestreamServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..87bfddc8c36a6 100644 --- a/google/cloud/video/livestream/v1/livestream_client.h +++ b/google/cloud/video/livestream/v1/livestream_client.h @@ -2499,6 +2499,356 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..518ced66585a6 100644 --- a/google/cloud/video/livestream/v1/livestream_connection.cc +++ b/google/cloud/video/livestream/v1/livestream_connection.cc @@ -434,6 +434,44 @@ 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"); +} + +StreamRange +LivestreamServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +LivestreamServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status LivestreamServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status LivestreamServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeLivestreamServiceConnection( Options options) { internal::CheckExpectedOptions> UpdatePool(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..a3bcc7fb9b38b 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,36 @@ 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; +} + +Idempotency LivestreamServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency LivestreamServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency LivestreamServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency LivestreamServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..8afa015b8633c 100644 --- a/google/cloud/video/livestream/v1/livestream_connection_idempotency_policy.h +++ b/google/cloud/video/livestream/v1/livestream_connection_idempotency_policy.h @@ -21,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -117,6 +119,24 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..8c062e6191bc0 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,29 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/video/stitcher/v1/internal/video_stitcher_auth_decorator.cc b/google/cloud/video/stitcher/v1/internal/video_stitcher_auth_decorator.cc index e8f54ad0d1024..5cc315f8e23f6 100644 --- a/google/cloud/video/stitcher/v1/internal/video_stitcher_auth_decorator.cc +++ b/google/cloud/video/stitcher/v1/internal/video_stitcher_auth_decorator.cc @@ -549,6 +549,39 @@ VideoStitcherServiceAuth::UpdateVodConfig( return child_->UpdateVodConfig(context, options, request); } +StatusOr +VideoStitcherServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr VideoStitcherServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status VideoStitcherServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status VideoStitcherServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + future> VideoStitcherServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/video/stitcher/v1/internal/video_stitcher_auth_decorator.h b/google/cloud/video/stitcher/v1/internal/video_stitcher_auth_decorator.h index e1fb32abc0d6e..563f464d358a2 100644 --- a/google/cloud/video/stitcher/v1/internal/video_stitcher_auth_decorator.h +++ b/google/cloud/video/stitcher/v1/internal/video_stitcher_auth_decorator.h @@ -281,6 +281,22 @@ class VideoStitcherServiceAuth : public VideoStitcherServiceStub { google::cloud::video::stitcher::v1::UpdateVodConfigRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/video/stitcher/v1/internal/video_stitcher_connection_impl.cc b/google/cloud/video/stitcher/v1/internal/video_stitcher_connection_impl.cc index b3d9447f10bfb..2ab2fb151041c 100644 --- a/google/cloud/video/stitcher/v1/internal/video_stitcher_connection_impl.cc +++ b/google/cloud/video/stitcher/v1/internal/video_stitcher_connection_impl.cc @@ -1629,6 +1629,80 @@ VideoStitcherServiceConnectionImpl::UpdateVodConfig( polling_policy(*current), __func__); } +StreamRange +VideoStitcherServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +VideoStitcherServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status VideoStitcherServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status VideoStitcherServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace video_stitcher_v1_internal } // namespace cloud diff --git a/google/cloud/video/stitcher/v1/internal/video_stitcher_connection_impl.h b/google/cloud/video/stitcher/v1/internal/video_stitcher_connection_impl.h index dcad50171986f..3523612f19fe4 100644 --- a/google/cloud/video/stitcher/v1/internal/video_stitcher_connection_impl.h +++ b/google/cloud/video/stitcher/v1/internal/video_stitcher_connection_impl.h @@ -279,6 +279,18 @@ class VideoStitcherServiceConnectionImpl future> UpdateVodConfig(google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/video/stitcher/v1/internal/video_stitcher_logging_decorator.cc b/google/cloud/video/stitcher/v1/internal/video_stitcher_logging_decorator.cc index 76dbccded35b1..11f059eee2f68 100644 --- a/google/cloud/video/stitcher/v1/internal/video_stitcher_logging_decorator.cc +++ b/google/cloud/video/stitcher/v1/internal/video_stitcher_logging_decorator.cc @@ -672,6 +672,52 @@ VideoStitcherServiceLogging::UpdateVodConfig( context, options, request, __func__, tracing_options_); } +StatusOr +VideoStitcherServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +VideoStitcherServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status VideoStitcherServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status VideoStitcherServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> VideoStitcherServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/video/stitcher/v1/internal/video_stitcher_logging_decorator.h b/google/cloud/video/stitcher/v1/internal/video_stitcher_logging_decorator.h index 886626b6f8e7b..c632efaaca40d 100644 --- a/google/cloud/video/stitcher/v1/internal/video_stitcher_logging_decorator.h +++ b/google/cloud/video/stitcher/v1/internal/video_stitcher_logging_decorator.h @@ -281,6 +281,22 @@ class VideoStitcherServiceLogging : public VideoStitcherServiceStub { google::cloud::video::stitcher::v1::UpdateVodConfigRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/video/stitcher/v1/internal/video_stitcher_metadata_decorator.cc b/google/cloud/video/stitcher/v1/internal/video_stitcher_metadata_decorator.cc index 663fa26331501..37a7ef5e45bc4 100644 --- a/google/cloud/video/stitcher/v1/internal/video_stitcher_metadata_decorator.cc +++ b/google/cloud/video/stitcher/v1/internal/video_stitcher_metadata_decorator.cc @@ -480,6 +480,40 @@ VideoStitcherServiceMetadata::UpdateVodConfig( return child_->UpdateVodConfig(context, options, request); } +StatusOr +VideoStitcherServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +VideoStitcherServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status VideoStitcherServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status VideoStitcherServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + future> VideoStitcherServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/video/stitcher/v1/internal/video_stitcher_metadata_decorator.h b/google/cloud/video/stitcher/v1/internal/video_stitcher_metadata_decorator.h index 4072da0b4f590..80834c1bc2074 100644 --- a/google/cloud/video/stitcher/v1/internal/video_stitcher_metadata_decorator.h +++ b/google/cloud/video/stitcher/v1/internal/video_stitcher_metadata_decorator.h @@ -282,6 +282,22 @@ class VideoStitcherServiceMetadata : public VideoStitcherServiceStub { google::cloud::video::stitcher::v1::UpdateVodConfigRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/video/stitcher/v1/internal/video_stitcher_stub.cc b/google/cloud/video/stitcher/v1/internal/video_stitcher_stub.cc index d800b939c41ee..a428fdb9b12c8 100644 --- a/google/cloud/video/stitcher/v1/internal/video_stitcher_stub.cc +++ b/google/cloud/video/stitcher/v1/internal/video_stitcher_stub.cc @@ -633,6 +633,52 @@ DefaultVideoStitcherServiceStub::UpdateVodConfig( return response; } +StatusOr +DefaultVideoStitcherServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultVideoStitcherServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultVideoStitcherServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultVideoStitcherServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + future> DefaultVideoStitcherServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/video/stitcher/v1/internal/video_stitcher_stub.h b/google/cloud/video/stitcher/v1/internal/video_stitcher_stub.h index 316c787117abc..9083f1cbabdf5 100644 --- a/google/cloud/video/stitcher/v1/internal/video_stitcher_stub.h +++ b/google/cloud/video/stitcher/v1/internal/video_stitcher_stub.h @@ -287,6 +287,22 @@ class VideoStitcherServiceStub { google::cloud::video::stitcher::v1::UpdateVodConfigRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -306,9 +322,13 @@ class DefaultVideoStitcherServiceStub : public VideoStitcherServiceStub { std::unique_ptr grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateCdnKey( google::cloud::CompletionQueue& cq, @@ -552,6 +572,22 @@ class DefaultVideoStitcherServiceStub : public VideoStitcherServiceStub { google::cloud::video::stitcher::v1::UpdateVodConfigRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -568,6 +604,8 @@ class DefaultVideoStitcherServiceStub : public VideoStitcherServiceStub { std::unique_ptr< google::cloud::video::stitcher::v1::VideoStitcherService::StubInterface> grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/video/stitcher/v1/internal/video_stitcher_stub_factory.cc b/google/cloud/video/stitcher/v1/internal/video_stitcher_stub_factory.cc index 57807695fac02..f664d7d1a12ca 100644 --- a/google/cloud/video/stitcher/v1/internal/video_stitcher_stub_factory.cc +++ b/google/cloud/video/stitcher/v1/internal/video_stitcher_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 CreateDefaultVideoStitcherServiceStub( auto service_grpc_stub = google::cloud::video::stitcher::v1::VideoStitcherService::NewStub( channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/video/stitcher/v1/internal/video_stitcher_tracing_connection.cc b/google/cloud/video/stitcher/v1/internal/video_stitcher_tracing_connection.cc index 696d3c51dc2f9..1a75d9648dd1d 100644 --- a/google/cloud/video/stitcher/v1/internal/video_stitcher_tracing_connection.cc +++ b/google/cloud/video/stitcher/v1/internal/video_stitcher_tracing_connection.cc @@ -574,6 +574,42 @@ VideoStitcherServiceTracingConnection::UpdateVodConfig( return internal::EndSpan(std::move(span), child_->UpdateVodConfig(operation)); } +StreamRange +VideoStitcherServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "video_stitcher_v1::VideoStitcherServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +VideoStitcherServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "video_stitcher_v1::VideoStitcherServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status VideoStitcherServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "video_stitcher_v1::VideoStitcherServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status VideoStitcherServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "video_stitcher_v1::VideoStitcherServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/video/stitcher/v1/internal/video_stitcher_tracing_connection.h b/google/cloud/video/stitcher/v1/internal/video_stitcher_tracing_connection.h index 73843eef351c1..b6bafe487ed7d 100644 --- a/google/cloud/video/stitcher/v1/internal/video_stitcher_tracing_connection.h +++ b/google/cloud/video/stitcher/v1/internal/video_stitcher_tracing_connection.h @@ -266,6 +266,18 @@ class VideoStitcherServiceTracingConnection future> UpdateVodConfig(google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/video/stitcher/v1/internal/video_stitcher_tracing_stub.cc b/google/cloud/video/stitcher/v1/internal/video_stitcher_tracing_stub.cc index c70bb3e8a2f69..e11682c414695 100644 --- a/google/cloud/video/stitcher/v1/internal/video_stitcher_tracing_stub.cc +++ b/google/cloud/video/stitcher/v1/internal/video_stitcher_tracing_stub.cc @@ -594,6 +594,52 @@ VideoStitcherServiceTracingStub::UpdateVodConfig( child_->UpdateVodConfig(context, options, request)); } +StatusOr +VideoStitcherServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.video.stitcher.v1.VideoStitcherService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +VideoStitcherServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.video.stitcher.v1.VideoStitcherService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status VideoStitcherServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.video.stitcher.v1.VideoStitcherService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status VideoStitcherServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.video.stitcher.v1.VideoStitcherService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + future> VideoStitcherServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/video/stitcher/v1/internal/video_stitcher_tracing_stub.h b/google/cloud/video/stitcher/v1/internal/video_stitcher_tracing_stub.h index 15a182b99a028..72173df39ce7c 100644 --- a/google/cloud/video/stitcher/v1/internal/video_stitcher_tracing_stub.h +++ b/google/cloud/video/stitcher/v1/internal/video_stitcher_tracing_stub.h @@ -281,6 +281,22 @@ class VideoStitcherServiceTracingStub : public VideoStitcherServiceStub { google::cloud::video::stitcher::v1::UpdateVodConfigRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/video/stitcher/v1/mocks/mock_video_stitcher_connection.h b/google/cloud/video/stitcher/v1/mocks/mock_video_stitcher_connection.h index 232ee35132f98..60560ecdfaddc 100644 --- a/google/cloud/video/stitcher/v1/mocks/mock_video_stitcher_connection.h +++ b/google/cloud/video/stitcher/v1/mocks/mock_video_stitcher_connection.h @@ -629,6 +629,21 @@ class MockVideoStitcherServiceConnection MOCK_METHOD(future>, UpdateVodConfig, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/video/stitcher/v1/video_stitcher_client.cc b/google/cloud/video/stitcher/v1/video_stitcher_client.cc index 8e0f21b6166aa..5bdf1c4fb8805 100644 --- a/google/cloud/video/stitcher/v1/video_stitcher_client.cc +++ b/google/cloud/video/stitcher/v1/video_stitcher_client.cc @@ -897,6 +897,68 @@ VideoStitcherServiceClient::UpdateVodConfig( return connection_->UpdateVodConfig(operation); } +StreamRange +VideoStitcherServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +VideoStitcherServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +VideoStitcherServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +VideoStitcherServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status VideoStitcherServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status VideoStitcherServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status VideoStitcherServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status VideoStitcherServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace video_stitcher_v1 } // namespace cloud diff --git a/google/cloud/video/stitcher/v1/video_stitcher_client.h b/google/cloud/video/stitcher/v1/video_stitcher_client.h index 7e3ecbd29bbf0..9875ee7e05251 100644 --- a/google/cloud/video/stitcher/v1/video_stitcher_client.h +++ b/google/cloud/video/stitcher/v1/video_stitcher_client.h @@ -2724,6 +2724,286 @@ class VideoStitcherServiceClient { UpdateVodConfig(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/video/stitcher/v1/video_stitcher_connection.cc b/google/cloud/video/stitcher/v1/video_stitcher_connection.cc index 336996b8ae23f..409974872c294 100644 --- a/google/cloud/video/stitcher/v1/video_stitcher_connection.cc +++ b/google/cloud/video/stitcher/v1/video_stitcher_connection.cc @@ -445,6 +445,30 @@ VideoStitcherServiceConnection::UpdateVodConfig( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +VideoStitcherServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +VideoStitcherServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status VideoStitcherServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status VideoStitcherServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeVideoStitcherServiceConnection(Options options) { internal::CheckExpectedOptions> UpdateVodConfig(google::longrunning::Operation const& operation); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/video/stitcher/v1/video_stitcher_connection_idempotency_policy.cc b/google/cloud/video/stitcher/v1/video_stitcher_connection_idempotency_policy.cc index 2f150b47fb311..88875f80dc4d0 100644 --- a/google/cloud/video/stitcher/v1/video_stitcher_connection_idempotency_policy.cc +++ b/google/cloud/video/stitcher/v1/video_stitcher_connection_idempotency_policy.cc @@ -190,6 +190,26 @@ Idempotency VideoStitcherServiceConnectionIdempotencyPolicy::UpdateVodConfig( return Idempotency::kNonIdempotent; } +Idempotency VideoStitcherServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency VideoStitcherServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency VideoStitcherServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency VideoStitcherServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultVideoStitcherServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/video/stitcher/v1/video_stitcher_connection_idempotency_policy.h b/google/cloud/video/stitcher/v1/video_stitcher_connection_idempotency_policy.h index 5a87d3a8f95fe..65211da76256a 100644 --- a/google/cloud/video/stitcher/v1/video_stitcher_connection_idempotency_policy.h +++ b/google/cloud/video/stitcher/v1/video_stitcher_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -137,6 +138,18 @@ class VideoStitcherServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency UpdateVodConfig( google::cloud::video::stitcher::v1::UpdateVodConfigRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/vision/v1/image_annotator_client.cc b/google/cloud/vision/v1/image_annotator_client.cc index f51c9c860fd79..be46ab32df486 100644 --- a/google/cloud/vision/v1/image_annotator_client.cc +++ b/google/cloud/vision/v1/image_annotator_client.cc @@ -167,6 +167,20 @@ ImageAnnotatorClient::AsyncBatchAnnotateFiles( return connection_->AsyncBatchAnnotateFiles(operation); } +StatusOr ImageAnnotatorClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr ImageAnnotatorClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace vision_v1 } // namespace cloud diff --git a/google/cloud/vision/v1/image_annotator_client.h b/google/cloud/vision/v1/image_annotator_client.h index 2b64612570923..f2294a7d14c49 100644 --- a/google/cloud/vision/v1/image_annotator_client.h +++ b/google/cloud/vision/v1/image_annotator_client.h @@ -492,6 +492,66 @@ class ImageAnnotatorClient { AsyncBatchAnnotateFiles(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/vision/v1/image_annotator_connection.cc b/google/cloud/vision/v1/image_annotator_connection.cc index 73cd66dadf6db..5ed79ef161d66 100644 --- a/google/cloud/vision/v1/image_annotator_connection.cc +++ b/google/cloud/vision/v1/image_annotator_connection.cc @@ -97,6 +97,11 @@ ImageAnnotatorConnection::AsyncBatchAnnotateFiles( Status(StatusCode::kUnimplemented, "not implemented")); } +StatusOr ImageAnnotatorConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeImageAnnotatorConnection( Options options) { internal::CheckExpectedOptions> AsyncBatchAnnotateFiles(google::longrunning::Operation const& operation); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/vision/v1/image_annotator_connection_idempotency_policy.cc b/google/cloud/vision/v1/image_annotator_connection_idempotency_policy.cc index d46f2f1883bdd..55a5db28103ed 100644 --- a/google/cloud/vision/v1/image_annotator_connection_idempotency_policy.cc +++ b/google/cloud/vision/v1/image_annotator_connection_idempotency_policy.cc @@ -54,6 +54,11 @@ Idempotency ImageAnnotatorConnectionIdempotencyPolicy::AsyncBatchAnnotateFiles( return Idempotency::kNonIdempotent; } +Idempotency ImageAnnotatorConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultImageAnnotatorConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/vision/v1/image_annotator_connection_idempotency_policy.h b/google/cloud/vision/v1/image_annotator_connection_idempotency_policy.h index 9712a6218950e..2b7be1118f605 100644 --- a/google/cloud/vision/v1/image_annotator_connection_idempotency_policy.h +++ b/google/cloud/vision/v1/image_annotator_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -49,6 +50,9 @@ class ImageAnnotatorConnectionIdempotencyPolicy { virtual google::cloud::Idempotency AsyncBatchAnnotateFiles( google::cloud::vision::v1::AsyncBatchAnnotateFilesRequest const& request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/vision/v1/internal/image_annotator_auth_decorator.cc b/google/cloud/vision/v1/internal/image_annotator_auth_decorator.cc index 3703bf0fa32e9..8ed299230a91f 100644 --- a/google/cloud/vision/v1/internal/image_annotator_auth_decorator.cc +++ b/google/cloud/vision/v1/internal/image_annotator_auth_decorator.cc @@ -107,6 +107,14 @@ ImageAnnotatorAuth::AsyncBatchAnnotateFiles( return child_->AsyncBatchAnnotateFiles(context, options, request); } +StatusOr ImageAnnotatorAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + future> ImageAnnotatorAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/vision/v1/internal/image_annotator_auth_decorator.h b/google/cloud/vision/v1/internal/image_annotator_auth_decorator.h index 8a6d47118d0a6..3f62ed6da4643 100644 --- a/google/cloud/vision/v1/internal/image_annotator_auth_decorator.h +++ b/google/cloud/vision/v1/internal/image_annotator_auth_decorator.h @@ -75,6 +75,10 @@ class ImageAnnotatorAuth : public ImageAnnotatorStub { google::cloud::vision::v1::AsyncBatchAnnotateFilesRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/vision/v1/internal/image_annotator_connection_impl.cc b/google/cloud/vision/v1/internal/image_annotator_connection_impl.cc index 734160097d584..4352394a101ac 100644 --- a/google/cloud/vision/v1/internal/image_annotator_connection_impl.cc +++ b/google/cloud/vision/v1/internal/image_annotator_connection_impl.cc @@ -279,6 +279,20 @@ ImageAnnotatorConnectionImpl::AsyncBatchAnnotateFiles( polling_policy(*current), __func__); } +StatusOr +ImageAnnotatorConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace vision_v1_internal } // namespace cloud diff --git a/google/cloud/vision/v1/internal/image_annotator_connection_impl.h b/google/cloud/vision/v1/internal/image_annotator_connection_impl.h index 501070c259811..be26c56021a96 100644 --- a/google/cloud/vision/v1/internal/image_annotator_connection_impl.h +++ b/google/cloud/vision/v1/internal/image_annotator_connection_impl.h @@ -88,6 +88,9 @@ class ImageAnnotatorConnectionImpl AsyncBatchAnnotateFiles( google::longrunning::Operation const& operation) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/vision/v1/internal/image_annotator_logging_decorator.cc b/google/cloud/vision/v1/internal/image_annotator_logging_decorator.cc index 70fe471b5e6f7..b3ae2a4f84ff2 100644 --- a/google/cloud/vision/v1/internal/image_annotator_logging_decorator.cc +++ b/google/cloud/vision/v1/internal/image_annotator_logging_decorator.cc @@ -125,6 +125,17 @@ ImageAnnotatorLogging::AsyncBatchAnnotateFiles( context, options, request, __func__, tracing_options_); } +StatusOr ImageAnnotatorLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> ImageAnnotatorLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/vision/v1/internal/image_annotator_logging_decorator.h b/google/cloud/vision/v1/internal/image_annotator_logging_decorator.h index a3cca02d28285..aaea856d8ed7c 100644 --- a/google/cloud/vision/v1/internal/image_annotator_logging_decorator.h +++ b/google/cloud/vision/v1/internal/image_annotator_logging_decorator.h @@ -75,6 +75,10 @@ class ImageAnnotatorLogging : public ImageAnnotatorStub { google::cloud::vision::v1::AsyncBatchAnnotateFilesRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/vision/v1/internal/image_annotator_metadata_decorator.cc b/google/cloud/vision/v1/internal/image_annotator_metadata_decorator.cc index 956a6294fec1a..6bab26c074210 100644 --- a/google/cloud/vision/v1/internal/image_annotator_metadata_decorator.cc +++ b/google/cloud/vision/v1/internal/image_annotator_metadata_decorator.cc @@ -98,6 +98,14 @@ ImageAnnotatorMetadata::AsyncBatchAnnotateFiles( return child_->AsyncBatchAnnotateFiles(context, options, request); } +StatusOr ImageAnnotatorMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + future> ImageAnnotatorMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/vision/v1/internal/image_annotator_metadata_decorator.h b/google/cloud/vision/v1/internal/image_annotator_metadata_decorator.h index 7bed383e4d4a5..ede69394b2e08 100644 --- a/google/cloud/vision/v1/internal/image_annotator_metadata_decorator.h +++ b/google/cloud/vision/v1/internal/image_annotator_metadata_decorator.h @@ -75,6 +75,10 @@ class ImageAnnotatorMetadata : public ImageAnnotatorStub { google::cloud::vision::v1::AsyncBatchAnnotateFilesRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/vision/v1/internal/image_annotator_stub.cc b/google/cloud/vision/v1/internal/image_annotator_stub.cc index f47d6d971d799..2e6ac8552c826 100644 --- a/google/cloud/vision/v1/internal/image_annotator_stub.cc +++ b/google/cloud/vision/v1/internal/image_annotator_stub.cc @@ -119,6 +119,18 @@ DefaultImageAnnotatorStub::AsyncBatchAnnotateFiles( return response; } +StatusOr +DefaultImageAnnotatorStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultImageAnnotatorStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/vision/v1/internal/image_annotator_stub.h b/google/cloud/vision/v1/internal/image_annotator_stub.h index abba2fa40de72..902aba00ca87b 100644 --- a/google/cloud/vision/v1/internal/image_annotator_stub.h +++ b/google/cloud/vision/v1/internal/image_annotator_stub.h @@ -74,6 +74,10 @@ class ImageAnnotatorStub { google::cloud::vision::v1::AsyncBatchAnnotateFilesRequest const& request) = 0; + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -92,9 +96,13 @@ class DefaultImageAnnotatorStub : public ImageAnnotatorStub { DefaultImageAnnotatorStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr BatchAnnotateImages( @@ -132,6 +140,10 @@ class DefaultImageAnnotatorStub : public ImageAnnotatorStub { google::cloud::vision::v1::AsyncBatchAnnotateFilesRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -147,6 +159,8 @@ class DefaultImageAnnotatorStub : public ImageAnnotatorStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/vision/v1/internal/image_annotator_stub_factory.cc b/google/cloud/vision/v1/internal/image_annotator_stub_factory.cc index 25b587691576c..2c44056459dd3 100644 --- a/google/cloud/vision/v1/internal/image_annotator_stub_factory.cc +++ b/google/cloud/vision/v1/internal/image_annotator_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 CreateDefaultImageAnnotatorStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::vision::v1::ImageAnnotator::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/vision/v1/internal/image_annotator_tracing_connection.cc b/google/cloud/vision/v1/internal/image_annotator_tracing_connection.cc index 8e7de88f6260b..d3f9a586c1eed 100644 --- a/google/cloud/vision/v1/internal/image_annotator_tracing_connection.cc +++ b/google/cloud/vision/v1/internal/image_annotator_tracing_connection.cc @@ -112,6 +112,15 @@ ImageAnnotatorTracingConnection::AsyncBatchAnnotateFiles( child_->AsyncBatchAnnotateFiles(operation)); } +StatusOr +ImageAnnotatorTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("vision_v1::ImageAnnotatorConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/vision/v1/internal/image_annotator_tracing_connection.h b/google/cloud/vision/v1/internal/image_annotator_tracing_connection.h index 9cff3e4989e22..f6909c98911e7 100644 --- a/google/cloud/vision/v1/internal/image_annotator_tracing_connection.h +++ b/google/cloud/vision/v1/internal/image_annotator_tracing_connection.h @@ -77,6 +77,9 @@ class ImageAnnotatorTracingConnection AsyncBatchAnnotateFiles( google::longrunning::Operation const& operation) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/vision/v1/internal/image_annotator_tracing_stub.cc b/google/cloud/vision/v1/internal/image_annotator_tracing_stub.cc index b10b23147b915..cefdb9eff1555 100644 --- a/google/cloud/vision/v1/internal/image_annotator_tracing_stub.cc +++ b/google/cloud/vision/v1/internal/image_annotator_tracing_stub.cc @@ -112,6 +112,18 @@ ImageAnnotatorTracingStub::AsyncBatchAnnotateFiles( child_->AsyncBatchAnnotateFiles(context, options, request)); } +StatusOr +ImageAnnotatorTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.vision.v1.ImageAnnotator", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + future> ImageAnnotatorTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/vision/v1/internal/image_annotator_tracing_stub.h b/google/cloud/vision/v1/internal/image_annotator_tracing_stub.h index a30c24566a8fd..f3d469ae3b9aa 100644 --- a/google/cloud/vision/v1/internal/image_annotator_tracing_stub.h +++ b/google/cloud/vision/v1/internal/image_annotator_tracing_stub.h @@ -74,6 +74,10 @@ class ImageAnnotatorTracingStub : public ImageAnnotatorStub { google::cloud::vision::v1::AsyncBatchAnnotateFilesRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/vision/v1/internal/product_search_auth_decorator.cc b/google/cloud/vision/v1/internal/product_search_auth_decorator.cc index 2e416b82aa6f2..f791395f3068d 100644 --- a/google/cloud/vision/v1/internal/product_search_auth_decorator.cc +++ b/google/cloud/vision/v1/internal/product_search_auth_decorator.cc @@ -233,6 +233,14 @@ StatusOr ProductSearchAuth::PurgeProducts( return child_->PurgeProducts(context, options, request); } +StatusOr ProductSearchAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + future> ProductSearchAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/vision/v1/internal/product_search_auth_decorator.h b/google/cloud/vision/v1/internal/product_search_auth_decorator.h index 306351126ea3b..f6d889454d4bd 100644 --- a/google/cloud/vision/v1/internal/product_search_auth_decorator.h +++ b/google/cloud/vision/v1/internal/product_search_auth_decorator.h @@ -142,6 +142,10 @@ class ProductSearchAuth : public ProductSearchStub { grpc::ClientContext& context, Options options, google::cloud::vision::v1::PurgeProductsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/vision/v1/internal/product_search_connection_impl.cc b/google/cloud/vision/v1/internal/product_search_connection_impl.cc index 6c3ee851799b4..7e59b679acafc 100644 --- a/google/cloud/vision/v1/internal/product_search_connection_impl.cc +++ b/google/cloud/vision/v1/internal/product_search_connection_impl.cc @@ -571,6 +571,20 @@ ProductSearchConnectionImpl::PurgeProducts( polling_policy(*current), __func__); } +StatusOr +ProductSearchConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace vision_v1_internal } // namespace cloud diff --git a/google/cloud/vision/v1/internal/product_search_connection_impl.h b/google/cloud/vision/v1/internal/product_search_connection_impl.h index 3dcdbdcaf338a..d524a138d580f 100644 --- a/google/cloud/vision/v1/internal/product_search_connection_impl.h +++ b/google/cloud/vision/v1/internal/product_search_connection_impl.h @@ -134,6 +134,9 @@ class ProductSearchConnectionImpl : public vision_v1::ProductSearchConnection { future> PurgeProducts(google::longrunning::Operation const& operation) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/vision/v1/internal/product_search_logging_decorator.cc b/google/cloud/vision/v1/internal/product_search_logging_decorator.cc index 422c31ac78b57..538196e0d2dd6 100644 --- a/google/cloud/vision/v1/internal/product_search_logging_decorator.cc +++ b/google/cloud/vision/v1/internal/product_search_logging_decorator.cc @@ -306,6 +306,17 @@ StatusOr ProductSearchLogging::PurgeProducts( context, options, request, __func__, tracing_options_); } +StatusOr ProductSearchLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> ProductSearchLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/vision/v1/internal/product_search_logging_decorator.h b/google/cloud/vision/v1/internal/product_search_logging_decorator.h index f03bbcbf5d339..0769e972b87f2 100644 --- a/google/cloud/vision/v1/internal/product_search_logging_decorator.h +++ b/google/cloud/vision/v1/internal/product_search_logging_decorator.h @@ -142,6 +142,10 @@ class ProductSearchLogging : public ProductSearchStub { grpc::ClientContext& context, Options options, google::cloud::vision::v1::PurgeProductsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/vision/v1/internal/product_search_metadata_decorator.cc b/google/cloud/vision/v1/internal/product_search_metadata_decorator.cc index c6ac784485c47..49775ca14c4c7 100644 --- a/google/cloud/vision/v1/internal/product_search_metadata_decorator.cc +++ b/google/cloud/vision/v1/internal/product_search_metadata_decorator.cc @@ -235,6 +235,14 @@ StatusOr ProductSearchMetadata::PurgeProducts( return child_->PurgeProducts(context, options, request); } +StatusOr ProductSearchMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + future> ProductSearchMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/vision/v1/internal/product_search_metadata_decorator.h b/google/cloud/vision/v1/internal/product_search_metadata_decorator.h index 56cd5f4a35ba9..3ec33019079d5 100644 --- a/google/cloud/vision/v1/internal/product_search_metadata_decorator.h +++ b/google/cloud/vision/v1/internal/product_search_metadata_decorator.h @@ -142,6 +142,10 @@ class ProductSearchMetadata : public ProductSearchStub { grpc::ClientContext& context, Options options, google::cloud::vision::v1::PurgeProductsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/vision/v1/internal/product_search_stub.cc b/google/cloud/vision/v1/internal/product_search_stub.cc index b06030624c391..ef616d0f29750 100644 --- a/google/cloud/vision/v1/internal/product_search_stub.cc +++ b/google/cloud/vision/v1/internal/product_search_stub.cc @@ -294,6 +294,17 @@ DefaultProductSearchStub::PurgeProducts( return response; } +StatusOr DefaultProductSearchStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultProductSearchStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/vision/v1/internal/product_search_stub.h b/google/cloud/vision/v1/internal/product_search_stub.h index 3a4d57c7681c6..31e70045721d4 100644 --- a/google/cloud/vision/v1/internal/product_search_stub.h +++ b/google/cloud/vision/v1/internal/product_search_stub.h @@ -137,6 +137,10 @@ class ProductSearchStub { grpc::ClientContext& context, Options options, google::cloud::vision::v1::PurgeProductsRequest const& request) = 0; + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -155,9 +159,13 @@ class DefaultProductSearchStub : public ProductSearchStub { DefaultProductSearchStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr CreateProductSet( grpc::ClientContext& context, Options const& options, @@ -262,6 +270,10 @@ class DefaultProductSearchStub : public ProductSearchStub { grpc::ClientContext& context, Options options, google::cloud::vision::v1::PurgeProductsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -277,6 +289,8 @@ class DefaultProductSearchStub : public ProductSearchStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/vision/v1/internal/product_search_stub_factory.cc b/google/cloud/vision/v1/internal/product_search_stub_factory.cc index 108f7ccf9967e..a3b69dc05f96a 100644 --- a/google/cloud/vision/v1/internal/product_search_stub_factory.cc +++ b/google/cloud/vision/v1/internal/product_search_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 CreateDefaultProductSearchStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::vision::v1::ProductSearch::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/vision/v1/internal/product_search_tracing_connection.cc b/google/cloud/vision/v1/internal/product_search_tracing_connection.cc index acf83f4e2aae3..cc9bc0c7bf52f 100644 --- a/google/cloud/vision/v1/internal/product_search_tracing_connection.cc +++ b/google/cloud/vision/v1/internal/product_search_tracing_connection.cc @@ -249,6 +249,15 @@ ProductSearchTracingConnection::PurgeProducts( return internal::EndSpan(std::move(span), child_->PurgeProducts(operation)); } +StatusOr +ProductSearchTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("vision_v1::ProductSearchConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/vision/v1/internal/product_search_tracing_connection.h b/google/cloud/vision/v1/internal/product_search_tracing_connection.h index b9ee8dd8928e5..4e085a40c25f2 100644 --- a/google/cloud/vision/v1/internal/product_search_tracing_connection.h +++ b/google/cloud/vision/v1/internal/product_search_tracing_connection.h @@ -123,6 +123,9 @@ class ProductSearchTracingConnection future> PurgeProducts(google::longrunning::Operation const& operation) override; + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/vision/v1/internal/product_search_tracing_stub.cc b/google/cloud/vision/v1/internal/product_search_tracing_stub.cc index 49e65ba9e0b74..13de798f13617 100644 --- a/google/cloud/vision/v1/internal/product_search_tracing_stub.cc +++ b/google/cloud/vision/v1/internal/product_search_tracing_stub.cc @@ -288,6 +288,17 @@ ProductSearchTracingStub::PurgeProducts( child_->PurgeProducts(context, options, request)); } +StatusOr ProductSearchTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.vision.v1.ProductSearch", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + future> ProductSearchTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/vision/v1/internal/product_search_tracing_stub.h b/google/cloud/vision/v1/internal/product_search_tracing_stub.h index fca48e224e424..eb17784b4cecd 100644 --- a/google/cloud/vision/v1/internal/product_search_tracing_stub.h +++ b/google/cloud/vision/v1/internal/product_search_tracing_stub.h @@ -141,6 +141,10 @@ class ProductSearchTracingStub : public ProductSearchStub { grpc::ClientContext& context, Options options, google::cloud::vision::v1::PurgeProductsRequest const& request) override; + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/vision/v1/mocks/mock_image_annotator_connection.h b/google/cloud/vision/v1/mocks/mock_image_annotator_connection.h index c1212e7f4169a..58b19fee51e33 100644 --- a/google/cloud/vision/v1/mocks/mock_image_annotator_connection.h +++ b/google/cloud/vision/v1/mocks/mock_image_annotator_connection.h @@ -145,6 +145,10 @@ class MockImageAnnotatorConnection StatusOr>, AsyncBatchAnnotateFiles, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/vision/v1/mocks/mock_product_search_connection.h b/google/cloud/vision/v1/mocks/mock_product_search_connection.h index 8ee27c974973b..cbd0b383284be 100644 --- a/google/cloud/vision/v1/mocks/mock_product_search_connection.h +++ b/google/cloud/vision/v1/mocks/mock_product_search_connection.h @@ -205,6 +205,10 @@ class MockProductSearchConnection : public vision_v1::ProductSearchConnection { future>, PurgeProducts, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/vision/v1/product_search_client.cc b/google/cloud/vision/v1/product_search_client.cc index 22473229b8c3e..cb81d01f27b83 100644 --- a/google/cloud/vision/v1/product_search_client.cc +++ b/google/cloud/vision/v1/product_search_client.cc @@ -402,6 +402,20 @@ ProductSearchClient::PurgeProducts( return connection_->PurgeProducts(operation); } +StatusOr ProductSearchClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr ProductSearchClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace vision_v1 } // namespace cloud diff --git a/google/cloud/vision/v1/product_search_client.h b/google/cloud/vision/v1/product_search_client.h index c4254a01d101f..f03f0659978ec 100644 --- a/google/cloud/vision/v1/product_search_client.h +++ b/google/cloud/vision/v1/product_search_client.h @@ -1711,6 +1711,66 @@ class ProductSearchClient { PurgeProducts(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/vision/v1/product_search_connection.cc b/google/cloud/vision/v1/product_search_connection.cc index c025e7c2c1c52..10d4a586fd92e 100644 --- a/google/cloud/vision/v1/product_search_connection.cc +++ b/google/cloud/vision/v1/product_search_connection.cc @@ -187,6 +187,11 @@ ProductSearchConnection::PurgeProducts(google::longrunning::Operation const&) { Status(StatusCode::kUnimplemented, "not implemented")); } +StatusOr ProductSearchConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeProductSearchConnection( Options options) { internal::CheckExpectedOptions> PurgeProducts(google::longrunning::Operation const& operation); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); }; /** diff --git a/google/cloud/vision/v1/product_search_connection_idempotency_policy.cc b/google/cloud/vision/v1/product_search_connection_idempotency_policy.cc index f1342d9cead3f..b1aecd1ca02ae 100644 --- a/google/cloud/vision/v1/product_search_connection_idempotency_policy.cc +++ b/google/cloud/vision/v1/product_search_connection_idempotency_policy.cc @@ -130,6 +130,11 @@ Idempotency ProductSearchConnectionIdempotencyPolicy::PurgeProducts( return Idempotency::kNonIdempotent; } +Idempotency ProductSearchConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultProductSearchConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/vision/v1/product_search_connection_idempotency_policy.h b/google/cloud/vision/v1/product_search_connection_idempotency_policy.h index 68ab0ac8dda4b..332faacd18c66 100644 --- a/google/cloud/vision/v1/product_search_connection_idempotency_policy.h +++ b/google/cloud/vision/v1/product_search_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -94,6 +95,9 @@ class ProductSearchConnectionIdempotencyPolicy { virtual google::cloud::Idempotency PurgeProducts( google::cloud::vision::v1::PurgeProductsRequest const& request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr 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..a4362b50412e0 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,56 @@ 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); +} + +StatusOr +VmMigrationAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr VmMigrationAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status VmMigrationAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status VmMigrationAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..2513ff431e9ee 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..adeb59edde09e 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,127 @@ 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__); +} + +StreamRange +VmMigrationConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +VmMigrationConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status VmMigrationConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status VmMigrationConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..8ab87eb01e70b 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..239e4fcdc92c6 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,74 @@ 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_); +} + +StatusOr +VmMigrationLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr VmMigrationLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status VmMigrationLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status VmMigrationLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..2942e1d4cf5e0 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..85d2d7921b1ce 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,56 @@ 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); +} + +StatusOr +VmMigrationMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr VmMigrationMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status VmMigrationMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status VmMigrationMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..fe86aa8e6ac2b 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..5bfab07c3414a 100644 --- a/google/cloud/vmmigration/v1/internal/vm_migration_stub.cc +++ b/google/cloud/vmmigration/v1/internal/vm_migration_stub.cc @@ -1104,6 +1104,74 @@ 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; +} + +StatusOr +DefaultVmMigrationStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultVmMigrationStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultVmMigrationStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultVmMigrationStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..5c02a11909bb2 100644 --- a/google/cloud/vmmigration/v1/internal/vm_migration_stub.h +++ b/google/cloud/vmmigration/v1/internal/vm_migration_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 @@ -460,6 +461,31 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -479,9 +505,16 @@ class DefaultVmMigrationStub : public VmMigrationStub { std::unique_ptr< google::cloud::vmmigration::v1::VmMigration::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListSources( grpc::ClientContext& context, Options const& options, @@ -910,6 +943,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -925,6 +982,10 @@ class DefaultVmMigrationStub : public VmMigrationStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..5edb0b61cd9ed 100644 --- a/google/cloud/vmmigration/v1/internal/vm_migration_stub_factory.cc +++ b/google/cloud/vmmigration/v1/internal/vm_migration_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,14 @@ std::shared_ptr CreateDefaultVmMigrationStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::vmmigration::v1::VmMigration::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..3a3aa58d3a1b6 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,62 @@ 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)); +} + +StreamRange +VmMigrationTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "vmmigration_v1::VmMigrationConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +VmMigrationTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("vmmigration_v1::VmMigrationConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status VmMigrationTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "vmmigration_v1::VmMigrationConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status VmMigrationTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "vmmigration_v1::VmMigrationConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..52b7aa742b58e 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,24 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..0948f81885cc8 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,74 @@ 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)); +} + +StatusOr +VmMigrationTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.vmmigration.v1.VmMigration", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr VmMigrationTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.vmmigration.v1.VmMigration", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status VmMigrationTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.vmmigration.v1.VmMigration", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status VmMigrationTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.vmmigration.v1.VmMigration", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..c57c7175c14df 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,30 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..b9b465cd14a2d 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,29 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..27b48268bb16c 100644 --- a/google/cloud/vmmigration/v1/vm_migration_client.cc +++ b/google/cloud/vmmigration/v1/vm_migration_client.cc @@ -1461,6 +1461,75 @@ 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); +} + +StreamRange VmMigrationClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange VmMigrationClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr VmMigrationClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr VmMigrationClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status VmMigrationClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status VmMigrationClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status VmMigrationClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status VmMigrationClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..be54c485a90eb 100644 --- a/google/cloud/vmmigration/v1/vm_migration_client.h +++ b/google/cloud/vmmigration/v1/vm_migration_client.h @@ -4410,6 +4410,356 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..1847624ec4327 100644 --- a/google/cloud/vmmigration/v1/vm_migration_connection.cc +++ b/google/cloud/vmmigration/v1/vm_migration_connection.cc @@ -781,6 +781,42 @@ 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"); +} + +StreamRange +VmMigrationConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr VmMigrationConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status VmMigrationConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status VmMigrationConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeVmMigrationConnection( Options options) { internal::CheckExpectedOptions ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..281545a7d89fc 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,36 @@ 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; +} + +Idempotency VmMigrationConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency VmMigrationConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency VmMigrationConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency VmMigrationConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..127e94ed6405e 100644 --- a/google/cloud/vmmigration/v1/vm_migration_connection_idempotency_policy.h +++ b/google/cloud/vmmigration/v1/vm_migration_connection_idempotency_policy.h @@ -21,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -184,6 +186,24 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest 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..b4bf3f5e4f434 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,73 @@ 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); +} + +StatusOr +VmwareEngineAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr VmwareEngineAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status VmwareEngineAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(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..a24eeed8567ca 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,38 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest 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..7425bcfaff6c5 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,154 @@ 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__); +} + +StreamRange +VmwareEngineConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +VmwareEngineConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status VmwareEngineConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(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..e9ac82bb16df4 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,30 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest 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..aca7cfcb95fde 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,97 @@ 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_); +} + +StatusOr +VmwareEngineLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr VmwareEngineLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status VmwareEngineLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(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..bdf169955bcd3 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,38 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest 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..4ab5aabe0576b 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,76 @@ 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); +} + +StatusOr +VmwareEngineMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr VmwareEngineMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status VmwareEngineMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(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..0b37015f6ac95 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,38 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest 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..351084629c476 100644 --- a/google/cloud/vmwareengine/v1/internal/vmware_engine_stub.cc +++ b/google/cloud/vmwareengine/v1/internal/vmware_engine_stub.cc @@ -1782,6 +1782,99 @@ 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; +} + +StatusOr +DefaultVmwareEngineStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultVmwareEngineStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultVmwareEngineStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..28c5f4a6d6a5b 100644 --- a/google/cloud/vmwareengine/v1/internal/vmware_engine_stub.h +++ b/google/cloud/vmwareengine/v1/internal/vmware_engine_stub.h @@ -24,7 +24,9 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include +#include #include #include #include @@ -742,6 +744,40 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -761,9 +797,18 @@ class DefaultVmwareEngineStub : public VmwareEngineStub { std::unique_ptr< google::cloud::vmwareengine::v1::VmwareEngine::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListPrivateClouds( @@ -1439,6 +1484,38 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -1454,6 +1531,11 @@ class DefaultVmwareEngineStub : public VmwareEngineStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..df05decb96461 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,10 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include +#include +#include #include #include @@ -44,9 +47,15 @@ std::shared_ptr CreateDefaultVmwareEngineStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::vmwareengine::v1::VmwareEngine::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..be0860616dbcb 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,79 @@ 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)); +} + +StreamRange +VmwareEngineTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "vmwareengine_v1::VmwareEngineConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +VmwareEngineTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "vmwareengine_v1::VmwareEngineConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status VmwareEngineTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "vmwareengine_v1::VmwareEngineConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(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..c46ca23a1a96e 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,30 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest 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..f767e2079290e 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,98 @@ 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)); +} + +StatusOr +VmwareEngineTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vmwareengine.v1.VmwareEngine", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr VmwareEngineTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vmwareengine.v1.VmwareEngine", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status VmwareEngineTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vmwareengine.v1.VmwareEngine", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(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..f6c3474e30e73 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,38 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest 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..16818a8d70ff2 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,38 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest 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..4f214ee195b13 100644 --- a/google/cloud/vmwareengine/v1/vmware_engine_client.cc +++ b/google/cloud/vmwareengine/v1/vmware_engine_client.cc @@ -2459,6 +2459,81 @@ 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); +} + +StreamRange VmwareEngineClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange VmwareEngineClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr VmwareEngineClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr VmwareEngineClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status VmwareEngineClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status VmwareEngineClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(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..aae5656772526 100644 --- a/google/cloud/vmwareengine/v1/vmware_engine_client.h +++ b/google/cloud/vmwareengine/v1/vmware_engine_client.h @@ -7721,6 +7721,385 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest 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..1a462086f0710 100644 --- a/google/cloud/vmwareengine/v1/vmware_engine_connection.cc +++ b/google/cloud/vmwareengine/v1/vmware_engine_connection.cc @@ -1210,6 +1210,53 @@ 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"); +} + +StreamRange +VmwareEngineConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr VmwareEngineConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status VmwareEngineConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeVmwareEngineConnection( Options options) { internal::CheckExpectedOptions> 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest 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..b359d0646d482 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,47 @@ 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; +} + +Idempotency VmwareEngineConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency VmwareEngineConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency VmwareEngineConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..e213aeceab6f2 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,10 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include +#include #include namespace google { @@ -305,6 +308,30 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest 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..878ec816ef207 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,32 @@ 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); +} + +StatusOr +VpcAccessServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr VpcAccessServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(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..0b5d993bf960f 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,18 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..4cd697f080216 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,87 @@ 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; + }); +} + +StreamRange +VpcAccessServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +VpcAccessServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + 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..7e109814590b2 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,15 @@ class VpcAccessServiceConnectionImpl future> DeleteConnector(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& 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..29ff75e9351ff 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,41 @@ 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_); +} + +StatusOr +VpcAccessServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr VpcAccessServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(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..a1d083eac1cb7 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,18 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..624e7468b77e7 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,32 @@ 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); +} + +StatusOr +VpcAccessServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr VpcAccessServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(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..5366cff472cfc 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,18 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..c705c1e2c0357 100644 --- a/google/cloud/vpcaccess/v1/internal/vpc_access_stub.cc +++ b/google/cloud/vpcaccess/v1/internal/vpc_access_stub.cc @@ -117,6 +117,42 @@ 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; +} + +StatusOr +DefaultVpcAccessServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultVpcAccessServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&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..2175022891943 100644 --- a/google/cloud/vpcaccess/v1/internal/vpc_access_stub.h +++ b/google/cloud/vpcaccess/v1/internal/vpc_access_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 @@ -67,6 +68,19 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -86,9 +100,16 @@ class DefaultVpcAccessServiceStub : public VpcAccessServiceStub { std::unique_ptr< google::cloud::vpcaccess::v1::VpcAccessService::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateConnector( google::cloud::CompletionQueue& cq, @@ -124,6 +145,18 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -139,6 +172,10 @@ class DefaultVpcAccessServiceStub : public VpcAccessServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..aa96230a5732e 100644 --- a/google/cloud/vpcaccess/v1/internal/vpc_access_stub_factory.cc +++ b/google/cloud/vpcaccess/v1/internal/vpc_access_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,14 @@ std::shared_ptr CreateDefaultVpcAccessServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::vpcaccess::v1::VpcAccessService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..356e2bd0d7fa7 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,37 @@ 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)); +} + +StreamRange +VpcAccessServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "vpcaccess_v1::VpcAccessServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +VpcAccessServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "vpcaccess_v1::VpcAccessServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + #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..26252d14071df 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,15 @@ class VpcAccessServiceTracingConnection future> DeleteConnector(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& 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..cc8fffc1da06a 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,42 @@ 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)); +} + +StatusOr +VpcAccessServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vpcaccess.v1.VpcAccessService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +VpcAccessServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vpcaccess.v1.VpcAccessService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(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..55d2e07d1aa01 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,18 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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..895d4cb7e353b 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,17 @@ class MockVpcAccessServiceConnection MOCK_METHOD(future>, DeleteConnector, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& 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..0d7b35a75bc8c 100644 --- a/google/cloud/vpcaccess/v1/vpc_access_client.cc +++ b/google/cloud/vpcaccess/v1/vpc_access_client.cc @@ -153,6 +153,45 @@ 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)); +} + +StreamRange +VpcAccessServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +VpcAccessServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr VpcAccessServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr VpcAccessServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(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..97357706e8bcc 100644 --- a/google/cloud/vpcaccess/v1/vpc_access_client.h +++ b/google/cloud/vpcaccess/v1/vpc_access_client.h @@ -457,6 +457,197 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& 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..cdac97532d021 100644 --- a/google/cloud/vpcaccess/v1/vpc_access_connection.cc +++ b/google/cloud/vpcaccess/v1/vpc_access_connection.cc @@ -98,6 +98,28 @@ 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>(); +} + +StreamRange +VpcAccessServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +VpcAccessServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeVpcAccessServiceConnection( Options options) { internal::CheckExpectedOptions> DeleteConnector(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& 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..7b05d70e5163f 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,21 @@ Idempotency VpcAccessServiceConnectionIdempotencyPolicy::DeleteConnector( return Idempotency::kNonIdempotent; } +Idempotency VpcAccessServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency VpcAccessServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency VpcAccessServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + 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..ea579985b8d5a 100644 --- a/google/cloud/vpcaccess/v1/vpc_access_connection_idempotency_policy.h +++ b/google/cloud/vpcaccess/v1/vpc_access_connection_idempotency_policy.h @@ -21,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -48,6 +50,15 @@ class VpcAccessServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteConnector( google::cloud::vpcaccess::v1::DeleteConnectorRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/webrisk/v1/internal/web_risk_auth_decorator.cc b/google/cloud/webrisk/v1/internal/web_risk_auth_decorator.cc index cb98200787d98..eeb716159222c 100644 --- a/google/cloud/webrisk/v1/internal/web_risk_auth_decorator.cc +++ b/google/cloud/webrisk/v1/internal/web_risk_auth_decorator.cc @@ -95,6 +95,39 @@ StatusOr WebRiskServiceAuth::SubmitUri( return child_->SubmitUri(context, options, request); } +StatusOr +WebRiskServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr WebRiskServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status WebRiskServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status WebRiskServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + future> WebRiskServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/webrisk/v1/internal/web_risk_auth_decorator.h b/google/cloud/webrisk/v1/internal/web_risk_auth_decorator.h index bc6abfca433fb..ab80057426186 100644 --- a/google/cloud/webrisk/v1/internal/web_risk_auth_decorator.h +++ b/google/cloud/webrisk/v1/internal/web_risk_auth_decorator.h @@ -68,6 +68,22 @@ class WebRiskServiceAuth : public WebRiskServiceStub { grpc::ClientContext& context, Options options, google::cloud::webrisk::v1::SubmitUriRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/webrisk/v1/internal/web_risk_connection_impl.cc b/google/cloud/webrisk/v1/internal/web_risk_connection_impl.cc index d9027750330bd..d25368c37ed55 100644 --- a/google/cloud/webrisk/v1/internal/web_risk_connection_impl.cc +++ b/google/cloud/webrisk/v1/internal/web_risk_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 @@ -209,6 +210,79 @@ WebRiskServiceConnectionImpl::SubmitUri( polling_policy(*current), __func__); } +StreamRange +WebRiskServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +WebRiskServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status WebRiskServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status WebRiskServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace webrisk_v1_internal } // namespace cloud diff --git a/google/cloud/webrisk/v1/internal/web_risk_connection_impl.h b/google/cloud/webrisk/v1/internal/web_risk_connection_impl.h index 96d3c265f5328..3c74b3104d50e 100644 --- a/google/cloud/webrisk/v1/internal/web_risk_connection_impl.h +++ b/google/cloud/webrisk/v1/internal/web_risk_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 @@ -76,6 +77,18 @@ class WebRiskServiceConnectionImpl future> SubmitUri( google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/webrisk/v1/internal/web_risk_logging_decorator.cc b/google/cloud/webrisk/v1/internal/web_risk_logging_decorator.cc index 1b95ecccafc26..5c1696053de22 100644 --- a/google/cloud/webrisk/v1/internal/web_risk_logging_decorator.cc +++ b/google/cloud/webrisk/v1/internal/web_risk_logging_decorator.cc @@ -114,6 +114,51 @@ StatusOr WebRiskServiceLogging::SubmitUri( context, options, request, __func__, tracing_options_); } +StatusOr +WebRiskServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr WebRiskServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status WebRiskServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status WebRiskServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> WebRiskServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/webrisk/v1/internal/web_risk_logging_decorator.h b/google/cloud/webrisk/v1/internal/web_risk_logging_decorator.h index 46d079dde356f..44c11d4d79f1f 100644 --- a/google/cloud/webrisk/v1/internal/web_risk_logging_decorator.h +++ b/google/cloud/webrisk/v1/internal/web_risk_logging_decorator.h @@ -68,6 +68,22 @@ class WebRiskServiceLogging : public WebRiskServiceStub { grpc::ClientContext& context, Options options, google::cloud::webrisk::v1::SubmitUriRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/webrisk/v1/internal/web_risk_metadata_decorator.cc b/google/cloud/webrisk/v1/internal/web_risk_metadata_decorator.cc index dc61f21ee9391..ccb2bb0076888 100644 --- a/google/cloud/webrisk/v1/internal/web_risk_metadata_decorator.cc +++ b/google/cloud/webrisk/v1/internal/web_risk_metadata_decorator.cc @@ -97,6 +97,39 @@ StatusOr WebRiskServiceMetadata::SubmitUri( return child_->SubmitUri(context, options, request); } +StatusOr +WebRiskServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr WebRiskServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status WebRiskServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status WebRiskServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + future> WebRiskServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/webrisk/v1/internal/web_risk_metadata_decorator.h b/google/cloud/webrisk/v1/internal/web_risk_metadata_decorator.h index 4779d9f463b43..b30df10fe4740 100644 --- a/google/cloud/webrisk/v1/internal/web_risk_metadata_decorator.h +++ b/google/cloud/webrisk/v1/internal/web_risk_metadata_decorator.h @@ -68,6 +68,22 @@ class WebRiskServiceMetadata : public WebRiskServiceStub { grpc::ClientContext& context, Options options, google::cloud::webrisk::v1::SubmitUriRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/webrisk/v1/internal/web_risk_stub.cc b/google/cloud/webrisk/v1/internal/web_risk_stub.cc index 224e37427dfb9..12e179c919b41 100644 --- a/google/cloud/webrisk/v1/internal/web_risk_stub.cc +++ b/google/cloud/webrisk/v1/internal/web_risk_stub.cc @@ -108,6 +108,52 @@ StatusOr DefaultWebRiskServiceStub::SubmitUri( return response; } +StatusOr +DefaultWebRiskServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultWebRiskServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultWebRiskServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultWebRiskServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + future> DefaultWebRiskServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/webrisk/v1/internal/web_risk_stub.h b/google/cloud/webrisk/v1/internal/web_risk_stub.h index f64a7ce3780e7..ee5e31f5c267c 100644 --- a/google/cloud/webrisk/v1/internal/web_risk_stub.h +++ b/google/cloud/webrisk/v1/internal/web_risk_stub.h @@ -67,6 +67,22 @@ class WebRiskServiceStub { grpc::ClientContext& context, Options options, google::cloud::webrisk::v1::SubmitUriRequest const& request) = 0; + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -85,9 +101,13 @@ class DefaultWebRiskServiceStub : public WebRiskServiceStub { DefaultWebRiskServiceStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + operations_(std::move(operations)) {} StatusOr ComputeThreatListDiff( @@ -118,6 +138,22 @@ class DefaultWebRiskServiceStub : public WebRiskServiceStub { grpc::ClientContext& context, Options options, google::cloud::webrisk::v1::SubmitUriRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -133,6 +169,8 @@ class DefaultWebRiskServiceStub : public WebRiskServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/webrisk/v1/internal/web_risk_stub_factory.cc b/google/cloud/webrisk/v1/internal/web_risk_stub_factory.cc index 66715d3e11aa2..afc6a58aa918d 100644 --- a/google/cloud/webrisk/v1/internal/web_risk_stub_factory.cc +++ b/google/cloud/webrisk/v1/internal/web_risk_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 CreateDefaultWebRiskServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::webrisk::v1::WebRiskService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_operations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/webrisk/v1/internal/web_risk_tracing_connection.cc b/google/cloud/webrisk/v1/internal/web_risk_tracing_connection.cc index a787c72f5231f..f2ad07212958c 100644 --- a/google/cloud/webrisk/v1/internal/web_risk_tracing_connection.cc +++ b/google/cloud/webrisk/v1/internal/web_risk_tracing_connection.cc @@ -18,6 +18,7 @@ #include "google/cloud/webrisk/v1/internal/web_risk_tracing_connection.h" #include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" #include #include @@ -95,6 +96,42 @@ WebRiskServiceTracingConnection::SubmitUri( return internal::EndSpan(std::move(span), child_->SubmitUri(operation)); } +StreamRange +WebRiskServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "webrisk_v1::WebRiskServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +WebRiskServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("webrisk_v1::WebRiskServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status WebRiskServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "webrisk_v1::WebRiskServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status WebRiskServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "webrisk_v1::WebRiskServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/webrisk/v1/internal/web_risk_tracing_connection.h b/google/cloud/webrisk/v1/internal/web_risk_tracing_connection.h index a443b3a1130e1..301a747f933ce 100644 --- a/google/cloud/webrisk/v1/internal/web_risk_tracing_connection.h +++ b/google/cloud/webrisk/v1/internal/web_risk_tracing_connection.h @@ -65,6 +65,18 @@ class WebRiskServiceTracingConnection future> SubmitUri( google::longrunning::Operation const& operation) override; + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/webrisk/v1/internal/web_risk_tracing_stub.cc b/google/cloud/webrisk/v1/internal/web_risk_tracing_stub.cc index 5dfe532ad3ef3..d42d4be687407 100644 --- a/google/cloud/webrisk/v1/internal/web_risk_tracing_stub.cc +++ b/google/cloud/webrisk/v1/internal/web_risk_tracing_stub.cc @@ -105,6 +105,52 @@ StatusOr WebRiskServiceTracingStub::SubmitUri( child_->SubmitUri(context, options, request)); } +StatusOr +WebRiskServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.webrisk.v1.WebRiskService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +WebRiskServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.webrisk.v1.WebRiskService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status WebRiskServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.webrisk.v1.WebRiskService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status WebRiskServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.webrisk.v1.WebRiskService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + future> WebRiskServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/webrisk/v1/internal/web_risk_tracing_stub.h b/google/cloud/webrisk/v1/internal/web_risk_tracing_stub.h index b438857156924..8b127a6d10738 100644 --- a/google/cloud/webrisk/v1/internal/web_risk_tracing_stub.h +++ b/google/cloud/webrisk/v1/internal/web_risk_tracing_stub.h @@ -67,6 +67,22 @@ class WebRiskServiceTracingStub : public WebRiskServiceStub { grpc::ClientContext& context, Options options, google::cloud::webrisk::v1::SubmitUriRequest const& request) override; + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/webrisk/v1/mocks/mock_web_risk_connection.h b/google/cloud/webrisk/v1/mocks/mock_web_risk_connection.h index 9670c695b6b35..494bf7eb98ff3 100644 --- a/google/cloud/webrisk/v1/mocks/mock_web_risk_connection.h +++ b/google/cloud/webrisk/v1/mocks/mock_web_risk_connection.h @@ -104,6 +104,21 @@ class MockWebRiskServiceConnection MOCK_METHOD(future>, SubmitUri, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/webrisk/v1/web_risk_client.cc b/google/cloud/webrisk/v1/web_risk_client.cc index 9aee177f23faf..a197b463ae3cf 100644 --- a/google/cloud/webrisk/v1/web_risk_client.cc +++ b/google/cloud/webrisk/v1/web_risk_client.cc @@ -135,6 +135,65 @@ WebRiskServiceClient::SubmitUri(google::longrunning::Operation const& operation, return connection_->SubmitUri(operation); } +StreamRange +WebRiskServiceClient::ListOperations(std::string const& name, + std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +WebRiskServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr WebRiskServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr WebRiskServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status WebRiskServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status WebRiskServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status WebRiskServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status WebRiskServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace webrisk_v1 } // namespace cloud diff --git a/google/cloud/webrisk/v1/web_risk_client.h b/google/cloud/webrisk/v1/web_risk_client.h index 9ba86aafb64d3..8fd0a6942a917 100644 --- a/google/cloud/webrisk/v1/web_risk_client.h +++ b/google/cloud/webrisk/v1/web_risk_client.h @@ -453,6 +453,286 @@ class WebRiskServiceClient { future> SubmitUri( google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/webrisk/v1/web_risk_connection.cc b/google/cloud/webrisk/v1/web_risk_connection.cc index dd9f35be138c5..dbf62d6a04812 100644 --- a/google/cloud/webrisk/v1/web_risk_connection.cc +++ b/google/cloud/webrisk/v1/web_risk_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 @@ -82,6 +83,29 @@ WebRiskServiceConnection::SubmitUri(google::longrunning::Operation const&) { Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +WebRiskServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr WebRiskServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status WebRiskServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status WebRiskServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeWebRiskServiceConnection( Options options) { internal::CheckExpectedOptions #include @@ -206,6 +207,18 @@ class WebRiskServiceConnection { virtual future> SubmitUri( google::longrunning::Operation const& operation); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; /** diff --git a/google/cloud/webrisk/v1/web_risk_connection_idempotency_policy.cc b/google/cloud/webrisk/v1/web_risk_connection_idempotency_policy.cc index 8aa400e23f1f1..50dc6bd7103c8 100644 --- a/google/cloud/webrisk/v1/web_risk_connection_idempotency_policy.cc +++ b/google/cloud/webrisk/v1/web_risk_connection_idempotency_policy.cc @@ -59,6 +59,26 @@ Idempotency WebRiskServiceConnectionIdempotencyPolicy::SubmitUri( return Idempotency::kNonIdempotent; } +Idempotency WebRiskServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency WebRiskServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency WebRiskServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency WebRiskServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + std::unique_ptr MakeDefaultWebRiskServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/webrisk/v1/web_risk_connection_idempotency_policy.h b/google/cloud/webrisk/v1/web_risk_connection_idempotency_policy.h index d0717fb025934..b203b4cb5ee50 100644 --- a/google/cloud/webrisk/v1/web_risk_connection_idempotency_policy.h +++ b/google/cloud/webrisk/v1/web_risk_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,18 @@ class WebRiskServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency SubmitUri( google::cloud::webrisk::v1::SubmitUriRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& 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..8c10904d8edb1 100644 --- a/google/cloud/workflows/v1/internal/workflows_auth_decorator.cc +++ b/google/cloud/workflows/v1/internal/workflows_auth_decorator.cc @@ -132,6 +132,48 @@ 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); +} + +StatusOr +WorkflowsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr WorkflowsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status WorkflowsAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(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..25eea29e5f9f7 100644 --- a/google/cloud/workflows/v1/internal/workflows_auth_decorator.h +++ b/google/cloud/workflows/v1/internal/workflows_auth_decorator.h @@ -84,6 +84,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest 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..20257b5755f61 100644 --- a/google/cloud/workflows/v1/internal/workflows_connection_impl.cc +++ b/google/cloud/workflows/v1/internal/workflows_connection_impl.cc @@ -385,6 +385,113 @@ 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__); +} + +StreamRange +WorkflowsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr WorkflowsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status WorkflowsConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(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..cb9a2cc89be2c 100644 --- a/google/cloud/workflows/v1/internal/workflows_connection_impl.h +++ b/google/cloud/workflows/v1/internal/workflows_connection_impl.h @@ -93,6 +93,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest 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..5cda213eb7124 100644 --- a/google/cloud/workflows/v1/internal/workflows_logging_decorator.cc +++ b/google/cloud/workflows/v1/internal/workflows_logging_decorator.cc @@ -152,6 +152,63 @@ 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_); +} + +StatusOr +WorkflowsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr WorkflowsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status WorkflowsLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(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..5b865002b1c14 100644 --- a/google/cloud/workflows/v1/internal/workflows_logging_decorator.h +++ b/google/cloud/workflows/v1/internal/workflows_logging_decorator.h @@ -84,6 +84,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest 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..275ce8d046a7e 100644 --- a/google/cloud/workflows/v1/internal/workflows_metadata_decorator.cc +++ b/google/cloud/workflows/v1/internal/workflows_metadata_decorator.cc @@ -123,6 +123,48 @@ 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); +} + +StatusOr +WorkflowsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr WorkflowsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status WorkflowsMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(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..3a8c024492d95 100644 --- a/google/cloud/workflows/v1/internal/workflows_metadata_decorator.h +++ b/google/cloud/workflows/v1/internal/workflows_metadata_decorator.h @@ -84,6 +84,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest 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..f4ade87d3ca34 100644 --- a/google/cloud/workflows/v1/internal/workflows_stub.cc +++ b/google/cloud/workflows/v1/internal/workflows_stub.cc @@ -142,6 +142,63 @@ 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; +} + +StatusOr +DefaultWorkflowsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultWorkflowsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultWorkflowsStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..cdef9da9a0a0f 100644 --- a/google/cloud/workflows/v1/internal/workflows_stub.h +++ b/google/cloud/workflows/v1/internal/workflows_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 @@ -77,6 +78,27 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -95,9 +117,16 @@ class DefaultWorkflowsStub : public WorkflowsStub { DefaultWorkflowsStub( std::unique_ptr grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListWorkflows( grpc::ClientContext& context, Options const& options, @@ -144,6 +173,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -159,6 +208,10 @@ class DefaultWorkflowsStub : public WorkflowsStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..d95f06d1caa24 100644 --- a/google/cloud/workflows/v1/internal/workflows_stub_factory.cc +++ b/google/cloud/workflows/v1/internal/workflows_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,8 +46,13 @@ std::shared_ptr CreateDefaultWorkflowsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::workflows::v1::Workflows::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..4b1564b30b513 100644 --- a/google/cloud/workflows/v1/internal/workflows_tracing_connection.cc +++ b/google/cloud/workflows/v1/internal/workflows_tracing_connection.cc @@ -140,6 +140,54 @@ 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)); +} + +StreamRange +WorkflowsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("workflows_v1::WorkflowsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +WorkflowsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("workflows_v1::WorkflowsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status WorkflowsTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = + internal::MakeSpan("workflows_v1::WorkflowsConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(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..a428f7a39d538 100644 --- a/google/cloud/workflows/v1/internal/workflows_tracing_connection.h +++ b/google/cloud/workflows/v1/internal/workflows_tracing_connection.h @@ -81,6 +81,21 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest 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..6edcce1958e42 100644 --- a/google/cloud/workflows/v1/internal/workflows_tracing_stub.cc +++ b/google/cloud/workflows/v1/internal/workflows_tracing_stub.cc @@ -133,6 +133,63 @@ 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)); +} + +StatusOr +WorkflowsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.workflows.v1.Workflows", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr WorkflowsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.workflows.v1.Workflows", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status WorkflowsTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.workflows.v1.Workflows", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(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..47282ef6aec0e 100644 --- a/google/cloud/workflows/v1/internal/workflows_tracing_stub.h +++ b/google/cloud/workflows/v1/internal/workflows_tracing_stub.h @@ -83,6 +83,26 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest 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..7f3554b63a273 100644 --- a/google/cloud/workflows/v1/mocks/mock_workflows_connection.h +++ b/google/cloud/workflows/v1/mocks/mock_workflows_connection.h @@ -169,6 +169,25 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest 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..70244e6743a9d 100644 --- a/google/cloud/workflows/v1/workflows_client.cc +++ b/google/cloud/workflows/v1/workflows_client.cc @@ -193,6 +193,60 @@ 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); +} + +StreamRange WorkflowsClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange WorkflowsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr WorkflowsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr WorkflowsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status WorkflowsClient::DeleteOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status WorkflowsClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(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..267e08845eb83 100644 --- a/google/cloud/workflows/v1/workflows_client.h +++ b/google/cloud/workflows/v1/workflows_client.h @@ -595,6 +595,283 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest 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..26b9d79bd1208 100644 --- a/google/cloud/workflows/v1/workflows_connection.cc +++ b/google/cloud/workflows/v1/workflows_connection.cc @@ -115,6 +115,36 @@ 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"); +} + +StreamRange WorkflowsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr WorkflowsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status WorkflowsConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeWorkflowsConnection(Options options) { internal::CheckExpectedOptions> UpdateWorkflow(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest 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..15ee7c844e8c4 100644 --- a/google/cloud/workflows/v1/workflows_connection_idempotency_policy.cc +++ b/google/cloud/workflows/v1/workflows_connection_idempotency_policy.cc @@ -59,6 +59,31 @@ 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; +} + +Idempotency WorkflowsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency WorkflowsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency WorkflowsConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..985272dfa8d35 100644 --- a/google/cloud/workflows/v1/workflows_connection_idempotency_policy.h +++ b/google/cloud/workflows/v1/workflows_connection_idempotency_policy.h @@ -21,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -50,6 +52,21 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest 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..130ae233577a1 100644 --- a/google/cloud/workstations/v1/internal/workstations_auth_decorator.cc +++ b/google/cloud/workstations/v1/internal/workstations_auth_decorator.cc @@ -445,6 +445,64 @@ 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); +} + +StatusOr +WorkstationsAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr WorkstationsAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status WorkstationsAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status WorkstationsAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(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..d9775402cd1a5 100644 --- a/google/cloud/workstations/v1/internal/workstations_auth_decorator.h +++ b/google/cloud/workstations/v1/internal/workstations_auth_decorator.h @@ -228,6 +228,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..cc974d6360b0b 100644 --- a/google/cloud/workstations/v1/internal/workstations_connection_impl.cc +++ b/google/cloud/workstations/v1/internal/workstations_connection_impl.cc @@ -1347,6 +1347,119 @@ 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__); +} + +StreamRange +WorkstationsConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(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::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +WorkstationsConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status WorkstationsConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status WorkstationsConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(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..bcab4455fb5bc 100644 --- a/google/cloud/workstations/v1/internal/workstations_connection_impl.h +++ b/google/cloud/workstations/v1/internal/workstations_connection_impl.h @@ -243,6 +243,27 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..fe7fa3303ee87 100644 --- a/google/cloud/workstations/v1/internal/workstations_logging_decorator.cc +++ b/google/cloud/workstations/v1/internal/workstations_logging_decorator.cc @@ -528,6 +528,85 @@ 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_); +} + +StatusOr +WorkstationsLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr WorkstationsLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status WorkstationsLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status WorkstationsLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(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..d601d33c4d93a 100644 --- a/google/cloud/workstations/v1/internal/workstations_logging_decorator.h +++ b/google/cloud/workstations/v1/internal/workstations_logging_decorator.h @@ -228,6 +228,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..577cc13353044 100644 --- a/google/cloud/workstations/v1/internal/workstations_metadata_decorator.cc +++ b/google/cloud/workstations/v1/internal/workstations_metadata_decorator.cc @@ -384,6 +384,67 @@ 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); +} + +StatusOr +WorkstationsMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr WorkstationsMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status WorkstationsMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status WorkstationsMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(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..0bec415e3e417 100644 --- a/google/cloud/workstations/v1/internal/workstations_metadata_decorator.h +++ b/google/cloud/workstations/v1/internal/workstations_metadata_decorator.h @@ -228,6 +228,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..6455830b1cb4b 100644 --- a/google/cloud/workstations/v1/internal/workstations_stub.cc +++ b/google/cloud/workstations/v1/internal/workstations_stub.cc @@ -513,6 +513,86 @@ 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; +} + +StatusOr +DefaultWorkstationsStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultWorkstationsStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultWorkstationsStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultWorkstationsStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + 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..7a059d6af9f5f 100644 --- a/google/cloud/workstations/v1/internal/workstations_stub.h +++ b/google/cloud/workstations/v1/internal/workstations_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -237,6 +238,35 @@ 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 StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -256,9 +286,15 @@ class DefaultWorkstationsStub : public WorkstationsStub { std::unique_ptr< google::cloud::workstations::v1::Workstations::StubInterface> grpc_stub, + std::unique_ptr + operations_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)), + operations_stub_(std::move(operations_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + operations_(std::move(operations)) {} StatusOr GetWorkstationCluster( @@ -449,6 +485,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -464,6 +528,9 @@ class DefaultWorkstationsStub : public WorkstationsStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + operations_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..5d4ca629f2791 100644 --- a/google/cloud/workstations/v1/internal/workstations_stub_factory.cc +++ b/google/cloud/workstations/v1/internal/workstations_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 CreateDefaultWorkstationsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::workstations::v1::Workstations::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::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_operations_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..57189684bc4c2 100644 --- a/google/cloud/workstations/v1/internal/workstations_tracing_connection.cc +++ b/google/cloud/workstations/v1/internal/workstations_tracing_connection.cc @@ -480,6 +480,67 @@ 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)); +} + +StreamRange +WorkstationsTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "workstations_v1::WorkstationsConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +WorkstationsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "workstations_v1::WorkstationsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status WorkstationsTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "workstations_v1::WorkstationsConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status WorkstationsTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "workstations_v1::WorkstationsConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(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..d66c537e5bc53 100644 --- a/google/cloud/workstations/v1/internal/workstations_tracing_connection.h +++ b/google/cloud/workstations/v1/internal/workstations_tracing_connection.h @@ -231,6 +231,27 @@ 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; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..9af897260429a 100644 --- a/google/cloud/workstations/v1/internal/workstations_tracing_stub.cc +++ b/google/cloud/workstations/v1/internal/workstations_tracing_stub.cc @@ -467,6 +467,85 @@ 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)); +} + +StatusOr +WorkstationsTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.workstations.v1.Workstations", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr WorkstationsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.workstations.v1.Workstations", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status WorkstationsTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.workstations.v1.Workstations", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status WorkstationsTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.workstations.v1.Workstations", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(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..40a27f78db463 100644 --- a/google/cloud/workstations/v1/internal/workstations_tracing_stub.h +++ b/google/cloud/workstations/v1/internal/workstations_tracing_stub.h @@ -227,6 +227,34 @@ 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; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest 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..2225a1802e4b5 100644 --- a/google/cloud/workstations/v1/mocks/mock_workstations_connection.h +++ b/google/cloud/workstations/v1/mocks/mock_workstations_connection.h @@ -556,6 +556,34 @@ 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)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest 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..1c2b0ab1d5cf6 100644 --- a/google/cloud/workstations/v1/workstations_client.cc +++ b/google/cloud/workstations/v1/workstations_client.cc @@ -693,6 +693,82 @@ 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); +} + +StreamRange WorkstationsClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange WorkstationsClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr WorkstationsClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr WorkstationsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status WorkstationsClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status WorkstationsClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status WorkstationsClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status WorkstationsClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(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..2d4b3d185eca5 100644 --- a/google/cloud/workstations/v1/workstations_client.h +++ b/google/cloud/workstations/v1/workstations_client.h @@ -2013,6 +2013,388 @@ 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 = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// NOTE: the `name` binding allows API services to override the binding + /// to use different resource name schemes, such as `users/*/operations`. To + /// override the binding, API services can add a binding such as + /// `"/v1/{name=users/*}/operations"` to their service configuration. + /// For backwards compatibility, the default name includes the operations + /// collection id, however overriding users must ensure the name binding + /// is the parent resource, without the operations collection id. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to 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.longrunning.Operation], 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.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L171} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L165} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L128} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L201} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + /// corresponding to `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to 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 [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L195} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L150} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L77} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest 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..d1a9520e37a0e 100644 --- a/google/cloud/workstations/v1/workstations_connection.cc +++ b/google/cloud/workstations/v1/workstations_connection.cc @@ -365,6 +365,45 @@ 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"); +} + +StreamRange +WorkstationsConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr WorkstationsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status WorkstationsConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status WorkstationsConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeWorkstationsConnection( Options options) { internal::CheckExpectedOptions 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); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest 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..024baff1b9ee9 100644 --- a/google/cloud/workstations/v1/workstations_connection_idempotency_policy.cc +++ b/google/cloud/workstations/v1/workstations_connection_idempotency_policy.cc @@ -137,6 +137,42 @@ 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; +} + +Idempotency WorkstationsConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency WorkstationsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency WorkstationsConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency WorkstationsConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + 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..53effe4e3ee9b 100644 --- a/google/cloud/workstations/v1/workstations_connection_idempotency_policy.h +++ b/google/cloud/workstations/v1/workstations_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -106,6 +108,27 @@ 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); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); }; std::unique_ptr From 50192415467edd67a18e0ec219e3a2b307c07d70 Mon Sep 17 00:00:00 2001 From: Yao Cui Date: Fri, 30 Aug 2024 14:55:33 +0000 Subject: [PATCH 3/4] Include pubsub schema service, it doesn't need manual changes --- generator/internal/make_generators.cc | 34 +++--- .../pubsub/internal/schema_auth_decorator.cc | 25 +++++ .../pubsub/internal/schema_auth_decorator.h | 12 +++ .../pubsub/internal/schema_connection_impl.cc | 40 +++++++ .../pubsub/internal/schema_connection_impl.h | 9 ++ .../internal/schema_logging_decorator.cc | 34 ++++++ .../internal/schema_logging_decorator.h | 12 +++ .../internal/schema_metadata_decorator.cc | 28 +++++ .../internal/schema_metadata_decorator.h | 12 +++ google/cloud/pubsub/internal/schema_stub.cc | 35 ++++++ google/cloud/pubsub/internal/schema_stub.h | 33 +++++- .../pubsub/internal/schema_stub_factory.cc | 5 +- .../internal/schema_tracing_connection.cc | 25 +++++ .../internal/schema_tracing_connection.h | 9 ++ .../pubsub/internal/schema_tracing_stub.cc | 34 ++++++ .../pubsub/internal/schema_tracing_stub.h | 12 +++ .../pubsub/mocks/mock_schema_connection.h | 13 +++ google/cloud/pubsub/schema_client.cc | 19 ++++ google/cloud/pubsub/schema_client.h | 102 ++++++++++++++++++ google/cloud/pubsub/schema_connection.cc | 16 +++ google/cloud/pubsub/schema_connection.h | 9 ++ .../schema_connection_idempotency_policy.cc | 16 +++ .../schema_connection_idempotency_policy.h | 10 ++ 23 files changed, 524 insertions(+), 20 deletions(-) diff --git a/generator/internal/make_generators.cc b/generator/internal/make_generators.cc index 3aec7bca48bff..fb0e5ef3a6d8e 100644 --- a/generator/internal/make_generators.cc +++ b/generator/internal/make_generators.cc @@ -61,26 +61,26 @@ std::vector> MakeGenerators( YAML::Node const& service_config, std::vector> const& vars) { std::vector mixin_methods; - if (service->file()->name() != "google/pubsub/v1/pubsub.proto" && - service->file()->name() != "google/pubsub/v1/schema.proto") { + if (service->file()->name() != "google/pubsub/v1/pubsub.proto") { mixin_methods = GetMixinMethods(service_config, *service); - 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; + // 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/google/cloud/pubsub/internal/schema_auth_decorator.cc b/google/cloud/pubsub/internal/schema_auth_decorator.cc index c683867469273..2e17b6289d56f 100644 --- a/google/cloud/pubsub/internal/schema_auth_decorator.cc +++ b/google/cloud/pubsub/internal/schema_auth_decorator.cc @@ -115,6 +115,31 @@ SchemaServiceAuth::ValidateMessage( return child_->ValidateMessage(context, options, request); } +StatusOr SchemaServiceAuth::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 SchemaServiceAuth::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 +SchemaServiceAuth::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 pubsub_internal } // namespace cloud diff --git a/google/cloud/pubsub/internal/schema_auth_decorator.h b/google/cloud/pubsub/internal/schema_auth_decorator.h index 785ebaee2aea2..e1255b8ab4794 100644 --- a/google/cloud/pubsub/internal/schema_auth_decorator.h +++ b/google/cloud/pubsub/internal/schema_auth_decorator.h @@ -78,6 +78,18 @@ class SchemaServiceAuth : public SchemaServiceStub { grpc::ClientContext& context, Options const& options, google::pubsub::v1::ValidateMessageRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options 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/pubsub/internal/schema_connection_impl.cc b/google/cloud/pubsub/internal/schema_connection_impl.cc index 871f803ee7c9f..eb13f3ecd60db 100644 --- a/google/cloud/pubsub/internal/schema_connection_impl.cc +++ b/google/cloud/pubsub/internal/schema_connection_impl.cc @@ -230,6 +230,46 @@ SchemaServiceConnectionImpl::ValidateMessage( *current, request, __func__); } +StatusOr SchemaServiceConnectionImpl::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 SchemaServiceConnectionImpl::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 +SchemaServiceConnectionImpl::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 pubsub_internal } // namespace cloud diff --git a/google/cloud/pubsub/internal/schema_connection_impl.h b/google/cloud/pubsub/internal/schema_connection_impl.h index 035e443b35650..5a035b71f08a2 100644 --- a/google/cloud/pubsub/internal/schema_connection_impl.h +++ b/google/cloud/pubsub/internal/schema_connection_impl.h @@ -78,6 +78,15 @@ class SchemaServiceConnectionImpl : public pubsub::SchemaServiceConnection { StatusOr ValidateMessage( google::pubsub::v1::ValidateMessageRequest 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/pubsub/internal/schema_logging_decorator.cc b/google/cloud/pubsub/internal/schema_logging_decorator.cc index 75e1ff42e22e6..83da27a9d0e2a 100644 --- a/google/cloud/pubsub/internal/schema_logging_decorator.cc +++ b/google/cloud/pubsub/internal/schema_logging_decorator.cc @@ -149,6 +149,40 @@ SchemaServiceLogging::ValidateMessage( context, options, request, __func__, tracing_options_); } +StatusOr SchemaServiceLogging::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 SchemaServiceLogging::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 +SchemaServiceLogging::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 pubsub_internal } // namespace cloud diff --git a/google/cloud/pubsub/internal/schema_logging_decorator.h b/google/cloud/pubsub/internal/schema_logging_decorator.h index 9c8d37ff57733..88309acd8a1c6 100644 --- a/google/cloud/pubsub/internal/schema_logging_decorator.h +++ b/google/cloud/pubsub/internal/schema_logging_decorator.h @@ -78,6 +78,18 @@ class SchemaServiceLogging : public SchemaServiceStub { grpc::ClientContext& context, Options const& options, google::pubsub::v1::ValidateMessageRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options 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/pubsub/internal/schema_metadata_decorator.cc b/google/cloud/pubsub/internal/schema_metadata_decorator.cc index 7ff0440ff935e..92a4d78dad6da 100644 --- a/google/cloud/pubsub/internal/schema_metadata_decorator.cc +++ b/google/cloud/pubsub/internal/schema_metadata_decorator.cc @@ -129,6 +129,34 @@ SchemaServiceMetadata::ValidateMessage( return child_->ValidateMessage(context, options, request); } +StatusOr SchemaServiceMetadata::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 SchemaServiceMetadata::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 +SchemaServiceMetadata::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 SchemaServiceMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/pubsub/internal/schema_metadata_decorator.h b/google/cloud/pubsub/internal/schema_metadata_decorator.h index b13c30683de28..795f7e5ccdfe4 100644 --- a/google/cloud/pubsub/internal/schema_metadata_decorator.h +++ b/google/cloud/pubsub/internal/schema_metadata_decorator.h @@ -78,6 +78,18 @@ class SchemaServiceMetadata : public SchemaServiceStub { grpc::ClientContext& context, Options const& options, google::pubsub::v1::ValidateMessageRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options 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/pubsub/internal/schema_stub.cc b/google/cloud/pubsub/internal/schema_stub.cc index fb2fb3335ec47..39fb5f991eed5 100644 --- a/google/cloud/pubsub/internal/schema_stub.cc +++ b/google/cloud/pubsub/internal/schema_stub.cc @@ -145,6 +145,41 @@ DefaultSchemaServiceStub::ValidateMessage( return response; } +StatusOr DefaultSchemaServiceStub::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 DefaultSchemaServiceStub::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 +DefaultSchemaServiceStub::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 pubsub_internal } // namespace cloud diff --git a/google/cloud/pubsub/internal/schema_stub.h b/google/cloud/pubsub/internal/schema_stub.h index 989303dc24603..1e67e671655fe 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 @@ -75,14 +76,29 @@ class SchemaServiceStub { virtual StatusOr ValidateMessage( grpc::ClientContext& context, Options const& options, google::pubsub::v1::ValidateMessageRequest 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 DefaultSchemaServiceStub : public SchemaServiceStub { public: explicit DefaultSchemaServiceStub( std::unique_ptr - 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 CreateSchema( grpc::ClientContext& context, Options const& options, @@ -124,8 +140,21 @@ class DefaultSchemaServiceStub : public SchemaServiceStub { grpc::ClientContext& context, Options const& options, google::pubsub::v1::ValidateMessageRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options 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_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/pubsub/internal/schema_stub_factory.cc b/google/cloud/pubsub/internal/schema_stub_factory.cc index 6e67e7d95ce69..1cb81f0e3fe16 100644 --- a/google/cloud/pubsub/internal/schema_stub_factory.cc +++ b/google/cloud/pubsub/internal/schema_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 CreateDefaultSchemaServiceStub( auto channel = auth->CreateChannel(options.get(), internal::MakeChannelArguments(options)); auto service_grpc_stub = google::pubsub::v1::SchemaService::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::make_shared( + std::move(service_grpc_stub), std::move(service_iampolicy_stub)); if (auth->RequiresConfigureContext()) { stub = diff --git a/google/cloud/pubsub/internal/schema_tracing_connection.cc b/google/cloud/pubsub/internal/schema_tracing_connection.cc index 6b8ebc54e6e93..798355ca8a6dc 100644 --- a/google/cloud/pubsub/internal/schema_tracing_connection.cc +++ b/google/cloud/pubsub/internal/schema_tracing_connection.cc @@ -124,6 +124,31 @@ SchemaServiceTracingConnection::ValidateMessage( return internal::EndSpan(*span, child_->ValidateMessage(request)); } +StatusOr SchemaServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = + internal::MakeSpan("pubsub::SchemaServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr SchemaServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = + internal::MakeSpan("pubsub::SchemaServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +SchemaServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = + internal::MakeSpan("pubsub::SchemaServiceConnection::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/pubsub/internal/schema_tracing_connection.h b/google/cloud/pubsub/internal/schema_tracing_connection.h index 004d7b850826d..ca2e5ef987a8b 100644 --- a/google/cloud/pubsub/internal/schema_tracing_connection.h +++ b/google/cloud/pubsub/internal/schema_tracing_connection.h @@ -69,6 +69,15 @@ class SchemaServiceTracingConnection : public pubsub::SchemaServiceConnection { StatusOr ValidateMessage( google::pubsub::v1::ValidateMessageRequest 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/pubsub/internal/schema_tracing_stub.cc b/google/cloud/pubsub/internal/schema_tracing_stub.cc index 6acf6ef8c336f..1594242ac3273 100644 --- a/google/cloud/pubsub/internal/schema_tracing_stub.cc +++ b/google/cloud/pubsub/internal/schema_tracing_stub.cc @@ -147,6 +147,40 @@ SchemaServiceTracingStub::ValidateMessage( child_->ValidateMessage(context, options, request)); } +StatusOr SchemaServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.pubsub.v1.SchemaService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr SchemaServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.pubsub.v1.SchemaService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +SchemaServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.pubsub.v1.SchemaService", + "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 MakeSchemaServiceTracingStub( diff --git a/google/cloud/pubsub/internal/schema_tracing_stub.h b/google/cloud/pubsub/internal/schema_tracing_stub.h index 71e6aac16c2e9..ee9f863191947 100644 --- a/google/cloud/pubsub/internal/schema_tracing_stub.h +++ b/google/cloud/pubsub/internal/schema_tracing_stub.h @@ -78,6 +78,18 @@ class SchemaServiceTracingStub : public SchemaServiceStub { grpc::ClientContext& context, Options const& options, google::pubsub::v1::ValidateMessageRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options 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/pubsub/mocks/mock_schema_connection.h b/google/cloud/pubsub/mocks/mock_schema_connection.h index 09150fde14c08..817b1cd8f7446 100644 --- a/google/cloud/pubsub/mocks/mock_schema_connection.h +++ b/google/cloud/pubsub/mocks/mock_schema_connection.h @@ -86,6 +86,19 @@ class MockSchemaServiceConnection : public pubsub::SchemaServiceConnection { ValidateMessage, (google::pubsub::v1::ValidateMessageRequest 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/pubsub/schema_client.cc b/google/cloud/pubsub/schema_client.cc index 89d77c482ccbc..656d8c62ffc14 100644 --- a/google/cloud/pubsub/schema_client.cc +++ b/google/cloud/pubsub/schema_client.cc @@ -180,6 +180,25 @@ SchemaServiceClient::ValidateMessage( return connection_->ValidateMessage(request); } +StatusOr SchemaServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr SchemaServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +SchemaServiceClient::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 pubsub } // namespace cloud diff --git a/google/cloud/pubsub/schema_client.h b/google/cloud/pubsub/schema_client.h index 63be6ed9b304d..3e734fdac50ff 100644 --- a/google/cloud/pubsub/schema_client.h +++ b/google/cloud/pubsub/schema_client.h @@ -679,6 +679,108 @@ class SchemaServiceClient { google::pubsub::v1::ValidateMessageRequest 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/pubsub/schema_connection.cc b/google/cloud/pubsub/schema_connection.cc index cb63fe9858581..6b38177af7724 100644 --- a/google/cloud/pubsub/schema_connection.cc +++ b/google/cloud/pubsub/schema_connection.cc @@ -96,6 +96,22 @@ SchemaServiceConnection::ValidateMessage( return Status(StatusCode::kUnimplemented, "not implemented"); } +StatusOr SchemaServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr SchemaServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +SchemaServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSchemaServiceConnection( Options options) { internal::CheckExpectedOptions ValidateMessage( google::pubsub::v1::ValidateMessageRequest 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/pubsub/schema_connection_idempotency_policy.cc b/google/cloud/pubsub/schema_connection_idempotency_policy.cc index 006b927b120e6..b4278089a2a24 100644 --- a/google/cloud/pubsub/schema_connection_idempotency_policy.cc +++ b/google/cloud/pubsub/schema_connection_idempotency_policy.cc @@ -84,6 +84,22 @@ Idempotency SchemaServiceConnectionIdempotencyPolicy::ValidateMessage( return Idempotency::kNonIdempotent; } +Idempotency SchemaServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency SchemaServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency SchemaServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultSchemaServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/pubsub/schema_connection_idempotency_policy.h b/google/cloud/pubsub/schema_connection_idempotency_policy.h index 305962ee1c612..d1b046d2b7acc 100644 --- a/google/cloud/pubsub/schema_connection_idempotency_policy.h +++ b/google/cloud/pubsub/schema_connection_idempotency_policy.h @@ -21,6 +21,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -66,6 +67,15 @@ class SchemaServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ValidateMessage( google::pubsub::v1::ValidateMessageRequest 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 20cbf2e114da7b8447db5a6b313b321bedee677f Mon Sep 17 00:00:00 2001 From: Yao Cui Date: Fri, 30 Aug 2024 19:45:16 +0000 Subject: [PATCH 4/4] Include pubsub Subscriber and Publisher services, it also includes manual changes --- generator/internal/make_generators.cc | 36 +++---- .../subscription_admin_auth_decorator.cc | 25 +++++ .../subscription_admin_auth_decorator.h | 12 +++ .../subscription_admin_connection_impl.cc | 40 +++++++ .../subscription_admin_connection_impl.h | 9 ++ .../subscription_admin_logging_decorator.cc | 34 ++++++ .../subscription_admin_logging_decorator.h | 12 +++ .../subscription_admin_metadata_decorator.cc | 28 +++++ .../subscription_admin_metadata_decorator.h | 12 +++ .../admin/internal/subscription_admin_stub.cc | 35 ++++++ .../admin/internal/subscription_admin_stub.h | 33 +++++- .../subscription_admin_stub_factory.cc | 4 +- .../subscription_admin_tracing_connection.cc | 27 +++++ .../subscription_admin_tracing_connection.h | 9 ++ .../subscription_admin_tracing_stub.cc | 34 ++++++ .../subscription_admin_tracing_stub.h | 12 +++ .../internal/topic_admin_auth_decorator.cc | 25 +++++ .../internal/topic_admin_auth_decorator.h | 12 +++ .../internal/topic_admin_connection_impl.cc | 40 +++++++ .../internal/topic_admin_connection_impl.h | 9 ++ .../internal/topic_admin_logging_decorator.cc | 34 ++++++ .../internal/topic_admin_logging_decorator.h | 12 +++ .../topic_admin_metadata_decorator.cc | 28 +++++ .../internal/topic_admin_metadata_decorator.h | 12 +++ .../pubsub/admin/internal/topic_admin_stub.cc | 35 ++++++ .../pubsub/admin/internal/topic_admin_stub.h | 33 +++++- .../internal/topic_admin_stub_factory.cc | 5 +- .../topic_admin_tracing_connection.cc | 25 +++++ .../internal/topic_admin_tracing_connection.h | 9 ++ .../internal/topic_admin_tracing_stub.cc | 34 ++++++ .../admin/internal/topic_admin_tracing_stub.h | 12 +++ .../mock_subscription_admin_connection.h | 13 +++ .../admin/mocks/mock_topic_admin_connection.h | 13 +++ .../pubsub/admin/subscription_admin_client.cc | 19 ++++ .../pubsub/admin/subscription_admin_client.h | 102 ++++++++++++++++++ .../admin/subscription_admin_connection.cc | 16 +++ .../admin/subscription_admin_connection.h | 9 ++ ...ion_admin_connection_idempotency_policy.cc | 16 +++ ...tion_admin_connection_idempotency_policy.h | 10 ++ .../cloud/pubsub/admin/topic_admin_client.cc | 19 ++++ .../cloud/pubsub/admin/topic_admin_client.h | 102 ++++++++++++++++++ .../pubsub/admin/topic_admin_connection.cc | 16 +++ .../pubsub/admin/topic_admin_connection.h | 9 ++ ...pic_admin_connection_idempotency_policy.cc | 16 +++ ...opic_admin_connection_idempotency_policy.h | 10 ++ .../internal/publisher_auth_decorator.cc | 25 +++++ .../internal/publisher_auth_decorator.h | 12 +++ .../internal/publisher_logging_decorator.cc | 34 ++++++ .../internal/publisher_logging_decorator.h | 12 +++ .../internal/publisher_metadata_decorator.cc | 28 +++++ .../internal/publisher_metadata_decorator.h | 12 +++ .../publisher_round_robin_decorator.cc | 19 ++++ .../publisher_round_robin_decorator.h | 12 +++ .../cloud/pubsub/internal/publisher_stub.cc | 35 ++++++ google/cloud/pubsub/internal/publisher_stub.h | 33 +++++- .../pubsub/internal/publisher_stub_factory.cc | 13 ++- .../pubsub/internal/publisher_tracing_stub.cc | 34 ++++++ .../pubsub/internal/publisher_tracing_stub.h | 12 +++ .../internal/subscriber_auth_decorator.cc | 25 +++++ .../internal/subscriber_auth_decorator.h | 12 +++ .../internal/subscriber_logging_decorator.cc | 34 ++++++ .../internal/subscriber_logging_decorator.h | 12 +++ .../internal/subscriber_metadata_decorator.cc | 28 +++++ .../internal/subscriber_metadata_decorator.h | 12 +++ .../subscriber_round_robin_decorator.cc | 19 ++++ .../subscriber_round_robin_decorator.h | 12 +++ .../cloud/pubsub/internal/subscriber_stub.cc | 35 ++++++ .../cloud/pubsub/internal/subscriber_stub.h | 33 +++++- .../internal/subscriber_stub_factory.cc | 14 +-- .../internal/subscriber_tracing_stub.cc | 34 ++++++ .../pubsub/internal/subscriber_tracing_stub.h | 12 +++ .../pubsub/testing/mock_publisher_stub.h | 16 +++ .../pubsub/testing/mock_subscriber_stub.h | 16 +++ 73 files changed, 1612 insertions(+), 40 deletions(-) diff --git a/generator/internal/make_generators.cc b/generator/internal/make_generators.cc index fb0e5ef3a6d8e..6672729f50408 100644 --- a/generator/internal/make_generators.cc +++ b/generator/internal/make_generators.cc @@ -61,27 +61,25 @@ std::vector> MakeGenerators( YAML::Node const& service_config, std::vector> const& vars) { std::vector mixin_methods; - if (service->file()->name() != "google/pubsub/v1/pubsub.proto") { - mixin_methods = GetMixinMethods(service_config, *service); - // 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; + mixin_methods = GetMixinMethods(service_config, *service); + // 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; VarsDictionary service_vars = diff --git a/google/cloud/pubsub/admin/internal/subscription_admin_auth_decorator.cc b/google/cloud/pubsub/admin/internal/subscription_admin_auth_decorator.cc index 0c2d63ea9401a..184344bbff929 100644 --- a/google/cloud/pubsub/admin/internal/subscription_admin_auth_decorator.cc +++ b/google/cloud/pubsub/admin/internal/subscription_admin_auth_decorator.cc @@ -132,6 +132,31 @@ StatusOr SubscriptionAdminAuth::Seek( return child_->Seek(context, options, request); } +StatusOr SubscriptionAdminAuth::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 SubscriptionAdminAuth::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 +SubscriptionAdminAuth::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 pubsub_admin_internal } // namespace cloud diff --git a/google/cloud/pubsub/admin/internal/subscription_admin_auth_decorator.h b/google/cloud/pubsub/admin/internal/subscription_admin_auth_decorator.h index fed02d184bb03..9ab07cfdd9390 100644 --- a/google/cloud/pubsub/admin/internal/subscription_admin_auth_decorator.h +++ b/google/cloud/pubsub/admin/internal/subscription_admin_auth_decorator.h @@ -86,6 +86,18 @@ class SubscriptionAdminAuth : public SubscriptionAdminStub { grpc::ClientContext& context, Options const& options, google::pubsub::v1::SeekRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options 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/pubsub/admin/internal/subscription_admin_connection_impl.cc b/google/cloud/pubsub/admin/internal/subscription_admin_connection_impl.cc index 7b7aca60d7db2..25aff24ab6faa 100644 --- a/google/cloud/pubsub/admin/internal/subscription_admin_connection_impl.cc +++ b/google/cloud/pubsub/admin/internal/subscription_admin_connection_impl.cc @@ -264,6 +264,46 @@ SubscriptionAdminConnectionImpl::Seek( *current, request, __func__); } +StatusOr SubscriptionAdminConnectionImpl::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 SubscriptionAdminConnectionImpl::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 +SubscriptionAdminConnectionImpl::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 pubsub_admin_internal } // namespace cloud diff --git a/google/cloud/pubsub/admin/internal/subscription_admin_connection_impl.h b/google/cloud/pubsub/admin/internal/subscription_admin_connection_impl.h index a20657330ffe2..2c3d4d8fbc5ef 100644 --- a/google/cloud/pubsub/admin/internal/subscription_admin_connection_impl.h +++ b/google/cloud/pubsub/admin/internal/subscription_admin_connection_impl.h @@ -85,6 +85,15 @@ class SubscriptionAdminConnectionImpl StatusOr Seek( google::pubsub::v1::SeekRequest 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/pubsub/admin/internal/subscription_admin_logging_decorator.cc b/google/cloud/pubsub/admin/internal/subscription_admin_logging_decorator.cc index d8f2f5c75857f..72e778d09d05f 100644 --- a/google/cloud/pubsub/admin/internal/subscription_admin_logging_decorator.cc +++ b/google/cloud/pubsub/admin/internal/subscription_admin_logging_decorator.cc @@ -172,6 +172,40 @@ StatusOr SubscriptionAdminLogging::Seek( context, options, request, __func__, tracing_options_); } +StatusOr SubscriptionAdminLogging::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 SubscriptionAdminLogging::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 +SubscriptionAdminLogging::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 pubsub_admin_internal } // namespace cloud diff --git a/google/cloud/pubsub/admin/internal/subscription_admin_logging_decorator.h b/google/cloud/pubsub/admin/internal/subscription_admin_logging_decorator.h index 385137c7172c4..426315708980f 100644 --- a/google/cloud/pubsub/admin/internal/subscription_admin_logging_decorator.h +++ b/google/cloud/pubsub/admin/internal/subscription_admin_logging_decorator.h @@ -86,6 +86,18 @@ class SubscriptionAdminLogging : public SubscriptionAdminStub { grpc::ClientContext& context, Options const& options, google::pubsub::v1::SeekRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options 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/pubsub/admin/internal/subscription_admin_metadata_decorator.cc b/google/cloud/pubsub/admin/internal/subscription_admin_metadata_decorator.cc index ebc54856182f4..fd6e0ee727023 100644 --- a/google/cloud/pubsub/admin/internal/subscription_admin_metadata_decorator.cc +++ b/google/cloud/pubsub/admin/internal/subscription_admin_metadata_decorator.cc @@ -155,6 +155,34 @@ StatusOr SubscriptionAdminMetadata::Seek( return child_->Seek(context, options, request); } +StatusOr SubscriptionAdminMetadata::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 SubscriptionAdminMetadata::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 +SubscriptionAdminMetadata::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 SubscriptionAdminMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/pubsub/admin/internal/subscription_admin_metadata_decorator.h b/google/cloud/pubsub/admin/internal/subscription_admin_metadata_decorator.h index e0aea8dbbaa8b..7c5b5f925cc43 100644 --- a/google/cloud/pubsub/admin/internal/subscription_admin_metadata_decorator.h +++ b/google/cloud/pubsub/admin/internal/subscription_admin_metadata_decorator.h @@ -87,6 +87,18 @@ class SubscriptionAdminMetadata : public SubscriptionAdminStub { grpc::ClientContext& context, Options const& options, google::pubsub::v1::SeekRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options 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/pubsub/admin/internal/subscription_admin_stub.cc b/google/cloud/pubsub/admin/internal/subscription_admin_stub.cc index d8a71be2ce7d7..ba709c67c220b 100644 --- a/google/cloud/pubsub/admin/internal/subscription_admin_stub.cc +++ b/google/cloud/pubsub/admin/internal/subscription_admin_stub.cc @@ -170,6 +170,41 @@ StatusOr DefaultSubscriptionAdminStub::Seek( return response; } +StatusOr DefaultSubscriptionAdminStub::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 DefaultSubscriptionAdminStub::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 +DefaultSubscriptionAdminStub::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 pubsub_admin_internal } // namespace cloud diff --git a/google/cloud/pubsub/admin/internal/subscription_admin_stub.h b/google/cloud/pubsub/admin/internal/subscription_admin_stub.h index 4de313c1c280b..1be96564ed9c7 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 @@ -83,13 +84,28 @@ class SubscriptionAdminStub { virtual StatusOr Seek( grpc::ClientContext& context, Options const& options, google::pubsub::v1::SeekRequest 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 DefaultSubscriptionAdminStub : public SubscriptionAdminStub { public: explicit DefaultSubscriptionAdminStub( - std::unique_ptr grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + std::unique_ptr grpc_stub, + std::unique_ptr iampolicy_stub) + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)) {} StatusOr CreateSubscription( grpc::ClientContext& context, Options const& options, @@ -139,8 +155,21 @@ class DefaultSubscriptionAdminStub : public SubscriptionAdminStub { grpc::ClientContext& context, Options const& options, google::pubsub::v1::SeekRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options 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_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/pubsub/admin/internal/subscription_admin_stub_factory.cc b/google/cloud/pubsub/admin/internal/subscription_admin_stub_factory.cc index 6fbfe5db4dbcd..2a7d85d22a410 100644 --- a/google/cloud/pubsub/admin/internal/subscription_admin_stub_factory.cc +++ b/google/cloud/pubsub/admin/internal/subscription_admin_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,9 +44,10 @@ std::shared_ptr CreateDefaultSubscriptionAdminStub( auto channel = auth->CreateChannel(options.get(), internal::MakeChannelArguments(options)); auto service_grpc_stub = google::pubsub::v1::Subscriber::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/pubsub/admin/internal/subscription_admin_tracing_connection.cc b/google/cloud/pubsub/admin/internal/subscription_admin_tracing_connection.cc index 1b44156919abb..208bbd7040924 100644 --- a/google/cloud/pubsub/admin/internal/subscription_admin_tracing_connection.cc +++ b/google/cloud/pubsub/admin/internal/subscription_admin_tracing_connection.cc @@ -142,6 +142,33 @@ SubscriptionAdminTracingConnection::Seek( return internal::EndSpan(*span, child_->Seek(request)); } +StatusOr +SubscriptionAdminTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "pubsub_admin::SubscriptionAdminConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +SubscriptionAdminTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "pubsub_admin::SubscriptionAdminConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +SubscriptionAdminTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "pubsub_admin::SubscriptionAdminConnection::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/pubsub/admin/internal/subscription_admin_tracing_connection.h b/google/cloud/pubsub/admin/internal/subscription_admin_tracing_connection.h index 86874cc2a125d..0fd9bb8bc6631 100644 --- a/google/cloud/pubsub/admin/internal/subscription_admin_tracing_connection.h +++ b/google/cloud/pubsub/admin/internal/subscription_admin_tracing_connection.h @@ -76,6 +76,15 @@ class SubscriptionAdminTracingConnection StatusOr Seek( google::pubsub::v1::SeekRequest 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/pubsub/admin/internal/subscription_admin_tracing_stub.cc b/google/cloud/pubsub/admin/internal/subscription_admin_tracing_stub.cc index 658a16b031b7a..fbd7ae20f5a31 100644 --- a/google/cloud/pubsub/admin/internal/subscription_admin_tracing_stub.cc +++ b/google/cloud/pubsub/admin/internal/subscription_admin_tracing_stub.cc @@ -171,6 +171,40 @@ StatusOr SubscriptionAdminTracingStub::Seek( child_->Seek(context, options, request)); } +StatusOr SubscriptionAdminTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.pubsub.v1.Subscriber", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr SubscriptionAdminTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.pubsub.v1.Subscriber", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +SubscriptionAdminTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.pubsub.v1.Subscriber", + "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 MakeSubscriptionAdminTracingStub( diff --git a/google/cloud/pubsub/admin/internal/subscription_admin_tracing_stub.h b/google/cloud/pubsub/admin/internal/subscription_admin_tracing_stub.h index 2398b57a16e26..146a6a68e9b6b 100644 --- a/google/cloud/pubsub/admin/internal/subscription_admin_tracing_stub.h +++ b/google/cloud/pubsub/admin/internal/subscription_admin_tracing_stub.h @@ -87,6 +87,18 @@ class SubscriptionAdminTracingStub : public SubscriptionAdminStub { grpc::ClientContext& context, Options const& options, google::pubsub::v1::SeekRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options 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/pubsub/admin/internal/topic_admin_auth_decorator.cc b/google/cloud/pubsub/admin/internal/topic_admin_auth_decorator.cc index a487c4b95f656..56ba11efcc87e 100644 --- a/google/cloud/pubsub/admin/internal/topic_admin_auth_decorator.cc +++ b/google/cloud/pubsub/admin/internal/topic_admin_auth_decorator.cc @@ -98,6 +98,31 @@ TopicAdminAuth::DetachSubscription( return child_->DetachSubscription(context, options, request); } +StatusOr TopicAdminAuth::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 TopicAdminAuth::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 +TopicAdminAuth::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 pubsub_admin_internal } // namespace cloud diff --git a/google/cloud/pubsub/admin/internal/topic_admin_auth_decorator.h b/google/cloud/pubsub/admin/internal/topic_admin_auth_decorator.h index 3f6f2c32d82be..6b9aa1d26c043 100644 --- a/google/cloud/pubsub/admin/internal/topic_admin_auth_decorator.h +++ b/google/cloud/pubsub/admin/internal/topic_admin_auth_decorator.h @@ -72,6 +72,18 @@ class TopicAdminAuth : public TopicAdminStub { grpc::ClientContext& context, Options const& options, google::pubsub::v1::DetachSubscriptionRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options 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/pubsub/admin/internal/topic_admin_connection_impl.cc b/google/cloud/pubsub/admin/internal/topic_admin_connection_impl.cc index ca45af1ef326f..f6f8d4b68b441 100644 --- a/google/cloud/pubsub/admin/internal/topic_admin_connection_impl.cc +++ b/google/cloud/pubsub/admin/internal/topic_admin_connection_impl.cc @@ -219,6 +219,46 @@ TopicAdminConnectionImpl::DetachSubscription( *current, request, __func__); } +StatusOr TopicAdminConnectionImpl::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 TopicAdminConnectionImpl::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 +TopicAdminConnectionImpl::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 pubsub_admin_internal } // namespace cloud diff --git a/google/cloud/pubsub/admin/internal/topic_admin_connection_impl.h b/google/cloud/pubsub/admin/internal/topic_admin_connection_impl.h index 7c54247906c3c..e775df7f37482 100644 --- a/google/cloud/pubsub/admin/internal/topic_admin_connection_impl.h +++ b/google/cloud/pubsub/admin/internal/topic_admin_connection_impl.h @@ -72,6 +72,15 @@ class TopicAdminConnectionImpl : public pubsub_admin::TopicAdminConnection { StatusOr DetachSubscription( google::pubsub::v1::DetachSubscriptionRequest 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/pubsub/admin/internal/topic_admin_logging_decorator.cc b/google/cloud/pubsub/admin/internal/topic_admin_logging_decorator.cc index 2e4bb324356e8..15e61c2bf2a4a 100644 --- a/google/cloud/pubsub/admin/internal/topic_admin_logging_decorator.cc +++ b/google/cloud/pubsub/admin/internal/topic_admin_logging_decorator.cc @@ -126,6 +126,40 @@ TopicAdminLogging::DetachSubscription( context, options, request, __func__, tracing_options_); } +StatusOr TopicAdminLogging::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 TopicAdminLogging::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 +TopicAdminLogging::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 pubsub_admin_internal } // namespace cloud diff --git a/google/cloud/pubsub/admin/internal/topic_admin_logging_decorator.h b/google/cloud/pubsub/admin/internal/topic_admin_logging_decorator.h index c4bbbaa640259..ef08e5ed57c92 100644 --- a/google/cloud/pubsub/admin/internal/topic_admin_logging_decorator.h +++ b/google/cloud/pubsub/admin/internal/topic_admin_logging_decorator.h @@ -72,6 +72,18 @@ class TopicAdminLogging : public TopicAdminStub { grpc::ClientContext& context, Options const& options, google::pubsub::v1::DetachSubscriptionRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options 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/pubsub/admin/internal/topic_admin_metadata_decorator.cc b/google/cloud/pubsub/admin/internal/topic_admin_metadata_decorator.cc index 5bfb957e6fb2d..703979521b35c 100644 --- a/google/cloud/pubsub/admin/internal/topic_admin_metadata_decorator.cc +++ b/google/cloud/pubsub/admin/internal/topic_admin_metadata_decorator.cc @@ -113,6 +113,34 @@ TopicAdminMetadata::DetachSubscription( return child_->DetachSubscription(context, options, request); } +StatusOr TopicAdminMetadata::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 TopicAdminMetadata::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 +TopicAdminMetadata::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 TopicAdminMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/pubsub/admin/internal/topic_admin_metadata_decorator.h b/google/cloud/pubsub/admin/internal/topic_admin_metadata_decorator.h index 8c8a82d446894..882dbed43d5b8 100644 --- a/google/cloud/pubsub/admin/internal/topic_admin_metadata_decorator.h +++ b/google/cloud/pubsub/admin/internal/topic_admin_metadata_decorator.h @@ -72,6 +72,18 @@ class TopicAdminMetadata : public TopicAdminStub { grpc::ClientContext& context, Options const& options, google::pubsub::v1::DetachSubscriptionRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options 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/pubsub/admin/internal/topic_admin_stub.cc b/google/cloud/pubsub/admin/internal/topic_admin_stub.cc index 445bab1ab1c67..7ea8f1dc71c84 100644 --- a/google/cloud/pubsub/admin/internal/topic_admin_stub.cc +++ b/google/cloud/pubsub/admin/internal/topic_admin_stub.cc @@ -123,6 +123,41 @@ DefaultTopicAdminStub::DetachSubscription( return response; } +StatusOr DefaultTopicAdminStub::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 DefaultTopicAdminStub::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 +DefaultTopicAdminStub::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 pubsub_admin_internal } // namespace cloud diff --git a/google/cloud/pubsub/admin/internal/topic_admin_stub.h b/google/cloud/pubsub/admin/internal/topic_admin_stub.h index f72e737b135e9..6ba2e4031baab 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 @@ -69,13 +70,28 @@ class TopicAdminStub { DetachSubscription( grpc::ClientContext& context, Options const& options, google::pubsub::v1::DetachSubscriptionRequest 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 DefaultTopicAdminStub : public TopicAdminStub { public: explicit DefaultTopicAdminStub( - std::unique_ptr grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + std::unique_ptr grpc_stub, + std::unique_ptr iampolicy_stub) + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)) {} StatusOr CreateTopic( grpc::ClientContext& context, Options const& options, @@ -111,8 +127,21 @@ class DefaultTopicAdminStub : public TopicAdminStub { grpc::ClientContext& context, Options const& options, google::pubsub::v1::DetachSubscriptionRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options 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_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/pubsub/admin/internal/topic_admin_stub_factory.cc b/google/cloud/pubsub/admin/internal/topic_admin_stub_factory.cc index 0d8cbc6088684..4d005f6edcecb 100644 --- a/google/cloud/pubsub/admin/internal/topic_admin_stub_factory.cc +++ b/google/cloud/pubsub/admin/internal/topic_admin_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 CreateDefaultTopicAdminStub( auto channel = auth->CreateChannel(options.get(), internal::MakeChannelArguments(options)); auto service_grpc_stub = google::pubsub::v1::Publisher::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::make_shared( + std::move(service_grpc_stub), std::move(service_iampolicy_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), std::move(stub)); diff --git a/google/cloud/pubsub/admin/internal/topic_admin_tracing_connection.cc b/google/cloud/pubsub/admin/internal/topic_admin_tracing_connection.cc index 4f461e3370068..fb18f165597a6 100644 --- a/google/cloud/pubsub/admin/internal/topic_admin_tracing_connection.cc +++ b/google/cloud/pubsub/admin/internal/topic_admin_tracing_connection.cc @@ -104,6 +104,31 @@ TopicAdminTracingConnection::DetachSubscription( return internal::EndSpan(*span, child_->DetachSubscription(request)); } +StatusOr TopicAdminTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = + internal::MakeSpan("pubsub_admin::TopicAdminConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr TopicAdminTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = + internal::MakeSpan("pubsub_admin::TopicAdminConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +TopicAdminTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "pubsub_admin::TopicAdminConnection::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/pubsub/admin/internal/topic_admin_tracing_connection.h b/google/cloud/pubsub/admin/internal/topic_admin_tracing_connection.h index 45931db6addbf..4ddd86cb69b66 100644 --- a/google/cloud/pubsub/admin/internal/topic_admin_tracing_connection.h +++ b/google/cloud/pubsub/admin/internal/topic_admin_tracing_connection.h @@ -63,6 +63,15 @@ class TopicAdminTracingConnection : public pubsub_admin::TopicAdminConnection { StatusOr DetachSubscription( google::pubsub::v1::DetachSubscriptionRequest 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/pubsub/admin/internal/topic_admin_tracing_stub.cc b/google/cloud/pubsub/admin/internal/topic_admin_tracing_stub.cc index a42f246a51c24..0bfd00a1850e5 100644 --- a/google/cloud/pubsub/admin/internal/topic_admin_tracing_stub.cc +++ b/google/cloud/pubsub/admin/internal/topic_admin_tracing_stub.cc @@ -124,6 +124,40 @@ TopicAdminTracingStub::DetachSubscription( context, *span, child_->DetachSubscription(context, options, request)); } +StatusOr TopicAdminTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.pubsub.v1.Publisher", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr TopicAdminTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.pubsub.v1.Publisher", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +TopicAdminTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.pubsub.v1.Publisher", + "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 MakeTopicAdminTracingStub( diff --git a/google/cloud/pubsub/admin/internal/topic_admin_tracing_stub.h b/google/cloud/pubsub/admin/internal/topic_admin_tracing_stub.h index b2384f933755a..6828e27c6e41d 100644 --- a/google/cloud/pubsub/admin/internal/topic_admin_tracing_stub.h +++ b/google/cloud/pubsub/admin/internal/topic_admin_tracing_stub.h @@ -72,6 +72,18 @@ class TopicAdminTracingStub : public TopicAdminStub { grpc::ClientContext& context, Options const& options, google::pubsub::v1::DetachSubscriptionRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options 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/pubsub/admin/mocks/mock_subscription_admin_connection.h b/google/cloud/pubsub/admin/mocks/mock_subscription_admin_connection.h index 87a87e04b6ad8..9b365a9595599 100644 --- a/google/cloud/pubsub/admin/mocks/mock_subscription_admin_connection.h +++ b/google/cloud/pubsub/admin/mocks/mock_subscription_admin_connection.h @@ -92,6 +92,19 @@ class MockSubscriptionAdminConnection MOCK_METHOD(StatusOr, Seek, (google::pubsub::v1::SeekRequest 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/pubsub/admin/mocks/mock_topic_admin_connection.h b/google/cloud/pubsub/admin/mocks/mock_topic_admin_connection.h index 46efce65d1e50..5225ec347bdb5 100644 --- a/google/cloud/pubsub/admin/mocks/mock_topic_admin_connection.h +++ b/google/cloud/pubsub/admin/mocks/mock_topic_admin_connection.h @@ -75,6 +75,19 @@ class MockTopicAdminConnection : public pubsub_admin::TopicAdminConnection { DetachSubscription, (google::pubsub::v1::DetachSubscriptionRequest 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/pubsub/admin/subscription_admin_client.cc b/google/cloud/pubsub/admin/subscription_admin_client.cc index df6dc2d0bbbef..1ba563dc4d2f5 100644 --- a/google/cloud/pubsub/admin/subscription_admin_client.cc +++ b/google/cloud/pubsub/admin/subscription_admin_client.cc @@ -216,6 +216,25 @@ StatusOr SubscriptionAdminClient::Seek( return connection_->Seek(request); } +StatusOr SubscriptionAdminClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr SubscriptionAdminClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +SubscriptionAdminClient::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 pubsub_admin } // namespace cloud diff --git a/google/cloud/pubsub/admin/subscription_admin_client.h b/google/cloud/pubsub/admin/subscription_admin_client.h index 7c2c663b784fa..241abad4579c3 100644 --- a/google/cloud/pubsub/admin/subscription_admin_client.h +++ b/google/cloud/pubsub/admin/subscription_admin_client.h @@ -930,6 +930,108 @@ class SubscriptionAdminClient { StatusOr Seek( google::pubsub::v1::SeekRequest 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/pubsub/admin/subscription_admin_connection.cc b/google/cloud/pubsub/admin/subscription_admin_connection.cc index 15692ad01e7fc..79084565231d2 100644 --- a/google/cloud/pubsub/admin/subscription_admin_connection.cc +++ b/google/cloud/pubsub/admin/subscription_admin_connection.cc @@ -109,6 +109,22 @@ StatusOr SubscriptionAdminConnection::Seek( return Status(StatusCode::kUnimplemented, "not implemented"); } +StatusOr SubscriptionAdminConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr SubscriptionAdminConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +SubscriptionAdminConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSubscriptionAdminConnection( Options options) { internal::CheckExpectedOptions Seek( google::pubsub::v1::SeekRequest 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/pubsub/admin/subscription_admin_connection_idempotency_policy.cc b/google/cloud/pubsub/admin/subscription_admin_connection_idempotency_policy.cc index 985904f85cdbe..eaf1035136548 100644 --- a/google/cloud/pubsub/admin/subscription_admin_connection_idempotency_policy.cc +++ b/google/cloud/pubsub/admin/subscription_admin_connection_idempotency_policy.cc @@ -94,6 +94,22 @@ Idempotency SubscriptionAdminConnectionIdempotencyPolicy::Seek( return Idempotency::kNonIdempotent; } +Idempotency SubscriptionAdminConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency SubscriptionAdminConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency SubscriptionAdminConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultSubscriptionAdminConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/pubsub/admin/subscription_admin_connection_idempotency_policy.h b/google/cloud/pubsub/admin/subscription_admin_connection_idempotency_policy.h index 8fedcd2060942..d722d63b00fab 100644 --- a/google/cloud/pubsub/admin/subscription_admin_connection_idempotency_policy.h +++ b/google/cloud/pubsub/admin/subscription_admin_connection_idempotency_policy.h @@ -21,6 +21,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -72,6 +73,15 @@ class SubscriptionAdminConnectionIdempotencyPolicy { virtual google::cloud::Idempotency Seek( google::pubsub::v1::SeekRequest 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/pubsub/admin/topic_admin_client.cc b/google/cloud/pubsub/admin/topic_admin_client.cc index 370d516bf8a4a..9a2e3a455c1a6 100644 --- a/google/cloud/pubsub/admin/topic_admin_client.cc +++ b/google/cloud/pubsub/admin/topic_admin_client.cc @@ -139,6 +139,25 @@ TopicAdminClient::DetachSubscription( return connection_->DetachSubscription(request); } +StatusOr TopicAdminClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr TopicAdminClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +TopicAdminClient::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 pubsub_admin } // namespace cloud diff --git a/google/cloud/pubsub/admin/topic_admin_client.h b/google/cloud/pubsub/admin/topic_admin_client.h index 6bc8b2220833a..99a552fdaaad6 100644 --- a/google/cloud/pubsub/admin/topic_admin_client.h +++ b/google/cloud/pubsub/admin/topic_admin_client.h @@ -573,6 +573,108 @@ class TopicAdminClient { google::pubsub::v1::DetachSubscriptionRequest 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/pubsub/admin/topic_admin_connection.cc b/google/cloud/pubsub/admin/topic_admin_connection.cc index fdd0ec70c6442..fef7f38791cca 100644 --- a/google/cloud/pubsub/admin/topic_admin_connection.cc +++ b/google/cloud/pubsub/admin/topic_admin_connection.cc @@ -85,6 +85,22 @@ TopicAdminConnection::DetachSubscription( return Status(StatusCode::kUnimplemented, "not implemented"); } +StatusOr TopicAdminConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr TopicAdminConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +TopicAdminConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeTopicAdminConnection( Options options) { internal::CheckExpectedOptions DetachSubscription( google::pubsub::v1::DetachSubscriptionRequest 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/pubsub/admin/topic_admin_connection_idempotency_policy.cc b/google/cloud/pubsub/admin/topic_admin_connection_idempotency_policy.cc index 6fe7f062b571f..16147a91973cd 100644 --- a/google/cloud/pubsub/admin/topic_admin_connection_idempotency_policy.cc +++ b/google/cloud/pubsub/admin/topic_admin_connection_idempotency_policy.cc @@ -74,6 +74,22 @@ Idempotency TopicAdminConnectionIdempotencyPolicy::DetachSubscription( return Idempotency::kNonIdempotent; } +Idempotency TopicAdminConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency TopicAdminConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency TopicAdminConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultTopicAdminConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/pubsub/admin/topic_admin_connection_idempotency_policy.h b/google/cloud/pubsub/admin/topic_admin_connection_idempotency_policy.h index de66bbf40b44f..33ef2aecc27d8 100644 --- a/google/cloud/pubsub/admin/topic_admin_connection_idempotency_policy.h +++ b/google/cloud/pubsub/admin/topic_admin_connection_idempotency_policy.h @@ -21,6 +21,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -59,6 +60,15 @@ class TopicAdminConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DetachSubscription( google::pubsub::v1::DetachSubscriptionRequest 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/pubsub/internal/publisher_auth_decorator.cc b/google/cloud/pubsub/internal/publisher_auth_decorator.cc index 3174dd1882cbe..d38f7de840f73 100644 --- a/google/cloud/pubsub/internal/publisher_auth_decorator.cc +++ b/google/cloud/pubsub/internal/publisher_auth_decorator.cc @@ -106,6 +106,31 @@ PublisherAuth::DetachSubscription( return child_->DetachSubscription(context, options, request); } +StatusOr PublisherAuth::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 PublisherAuth::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 +PublisherAuth::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> PublisherAuth::AsyncPublish(google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/pubsub/internal/publisher_auth_decorator.h b/google/cloud/pubsub/internal/publisher_auth_decorator.h index 84a70d8c619b5..2f81f5fef921a 100644 --- a/google/cloud/pubsub/internal/publisher_auth_decorator.h +++ b/google/cloud/pubsub/internal/publisher_auth_decorator.h @@ -76,6 +76,18 @@ class PublisherAuth : public PublisherStub { grpc::ClientContext& context, Options const& options, google::pubsub::v1::DetachSubscriptionRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncPublish( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/pubsub/internal/publisher_logging_decorator.cc b/google/cloud/pubsub/internal/publisher_logging_decorator.cc index d73ef8dc96c2f..441eb3e7072f2 100644 --- a/google/cloud/pubsub/internal/publisher_logging_decorator.cc +++ b/google/cloud/pubsub/internal/publisher_logging_decorator.cc @@ -137,6 +137,40 @@ PublisherLogging::DetachSubscription( context, options, request, __func__, tracing_options_); } +StatusOr PublisherLogging::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 PublisherLogging::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 +PublisherLogging::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> PublisherLogging::AsyncPublish( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/pubsub/internal/publisher_logging_decorator.h b/google/cloud/pubsub/internal/publisher_logging_decorator.h index 90a894eb71879..7f5028d399ebd 100644 --- a/google/cloud/pubsub/internal/publisher_logging_decorator.h +++ b/google/cloud/pubsub/internal/publisher_logging_decorator.h @@ -76,6 +76,18 @@ class PublisherLogging : public PublisherStub { grpc::ClientContext& context, Options const& options, google::pubsub::v1::DetachSubscriptionRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncPublish( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/pubsub/internal/publisher_metadata_decorator.cc b/google/cloud/pubsub/internal/publisher_metadata_decorator.cc index b8537b6b30075..2eb9e3771b152 100644 --- a/google/cloud/pubsub/internal/publisher_metadata_decorator.cc +++ b/google/cloud/pubsub/internal/publisher_metadata_decorator.cc @@ -121,6 +121,34 @@ PublisherMetadata::DetachSubscription( return child_->DetachSubscription(context, options, request); } +StatusOr PublisherMetadata::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 PublisherMetadata::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 +PublisherMetadata::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> PublisherMetadata::AsyncPublish( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/pubsub/internal/publisher_metadata_decorator.h b/google/cloud/pubsub/internal/publisher_metadata_decorator.h index b5fe3d6f8463a..1a6c724c4f3b9 100644 --- a/google/cloud/pubsub/internal/publisher_metadata_decorator.h +++ b/google/cloud/pubsub/internal/publisher_metadata_decorator.h @@ -76,6 +76,18 @@ class PublisherMetadata : public PublisherStub { grpc::ClientContext& context, Options const& options, google::pubsub::v1::DetachSubscriptionRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncPublish( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/pubsub/internal/publisher_round_robin_decorator.cc b/google/cloud/pubsub/internal/publisher_round_robin_decorator.cc index 74fa4d3bfd43d..d23db6750ebb3 100644 --- a/google/cloud/pubsub/internal/publisher_round_robin_decorator.cc +++ b/google/cloud/pubsub/internal/publisher_round_robin_decorator.cc @@ -88,6 +88,25 @@ PublisherRoundRobin::DetachSubscription( return Child()->DetachSubscription(context, options, request); } +StatusOr PublisherRoundRobin::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return Child()->SetIamPolicy(context, options, request); +} + +StatusOr PublisherRoundRobin::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return Child()->GetIamPolicy(context, options, request); +} + +StatusOr +PublisherRoundRobin::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return Child()->TestIamPermissions(context, options, request); +} + future> PublisherRoundRobin::AsyncPublish( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/pubsub/internal/publisher_round_robin_decorator.h b/google/cloud/pubsub/internal/publisher_round_robin_decorator.h index 48b116529960f..c11cbe985b7f6 100644 --- a/google/cloud/pubsub/internal/publisher_round_robin_decorator.h +++ b/google/cloud/pubsub/internal/publisher_round_robin_decorator.h @@ -74,6 +74,18 @@ class PublisherRoundRobin : public PublisherStub { grpc::ClientContext& context, Options const& options, google::pubsub::v1::DetachSubscriptionRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncPublish( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/pubsub/internal/publisher_stub.cc b/google/cloud/pubsub/internal/publisher_stub.cc index 4edac46ba5541..8b6401ee66bdd 100644 --- a/google/cloud/pubsub/internal/publisher_stub.cc +++ b/google/cloud/pubsub/internal/publisher_stub.cc @@ -134,6 +134,41 @@ DefaultPublisherStub::DetachSubscription( return response; } +StatusOr DefaultPublisherStub::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 DefaultPublisherStub::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 +DefaultPublisherStub::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> DefaultPublisherStub::AsyncPublish( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/pubsub/internal/publisher_stub.h b/google/cloud/pubsub/internal/publisher_stub.h index 3af6d0ffbfc99..0345b4472e658 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 @@ -76,6 +77,19 @@ class PublisherStub { grpc::ClientContext& context, Options const& options, google::pubsub::v1::DetachSubscriptionRequest 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> AsyncPublish( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -86,8 +100,10 @@ class PublisherStub { class DefaultPublisherStub : public PublisherStub { public: explicit DefaultPublisherStub( - std::unique_ptr grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + std::unique_ptr grpc_stub, + std::unique_ptr iampolicy_stub) + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)) {} StatusOr CreateTopic( grpc::ClientContext& context, Options const& options, @@ -127,6 +143,18 @@ class DefaultPublisherStub : public PublisherStub { grpc::ClientContext& context, Options const& options, google::pubsub::v1::DetachSubscriptionRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncPublish( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -135,6 +163,7 @@ class DefaultPublisherStub : public PublisherStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/pubsub/internal/publisher_stub_factory.cc b/google/cloud/pubsub/internal/publisher_stub_factory.cc index 927cfe58bad6a..6bd8e151f81a9 100644 --- a/google/cloud/pubsub/internal/publisher_stub_factory.cc +++ b/google/cloud/pubsub/internal/publisher_stub_factory.cc @@ -25,6 +25,8 @@ #include "google/cloud/internal/api_client_header.h" #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" +#include +#include namespace google { namespace cloud { @@ -55,11 +57,12 @@ std::shared_ptr CreateGrpcChannel( std::shared_ptr MakeRoundRobinPublisherStub( google::cloud::CompletionQueue cq, Options const& options) { - return CreateDecoratedStubs( - std::move(cq), options, [](std::shared_ptr c) { - return std::make_shared( - google::pubsub::v1::Publisher::NewStub(std::move(c))); - }); + return CreateDecoratedStubs(std::move(cq), options, + [](std::shared_ptr c) { + return std::make_shared( + google::pubsub::v1::Publisher::NewStub(c), + google::iam::v1::IAMPolicy::NewStub(c)); + }); } std::shared_ptr CreateDecoratedStubs( diff --git a/google/cloud/pubsub/internal/publisher_tracing_stub.cc b/google/cloud/pubsub/internal/publisher_tracing_stub.cc index 628eebdc093f5..6c9790e0a7048 100644 --- a/google/cloud/pubsub/internal/publisher_tracing_stub.cc +++ b/google/cloud/pubsub/internal/publisher_tracing_stub.cc @@ -133,6 +133,40 @@ PublisherTracingStub::DetachSubscription( context, *span, child_->DetachSubscription(context, options, request)); } +StatusOr PublisherTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.pubsub.v1.Publisher", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr PublisherTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.pubsub.v1.Publisher", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +PublisherTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.pubsub.v1.Publisher", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> PublisherTracingStub::AsyncPublish( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/pubsub/internal/publisher_tracing_stub.h b/google/cloud/pubsub/internal/publisher_tracing_stub.h index f77270c459618..9423dee21cc8d 100644 --- a/google/cloud/pubsub/internal/publisher_tracing_stub.h +++ b/google/cloud/pubsub/internal/publisher_tracing_stub.h @@ -76,6 +76,18 @@ class PublisherTracingStub : public PublisherStub { grpc::ClientContext& context, Options const& options, google::pubsub::v1::DetachSubscriptionRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncPublish( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/pubsub/internal/subscriber_auth_decorator.cc b/google/cloud/pubsub/internal/subscriber_auth_decorator.cc index d7a6cc6a9c803..d9c0b49ad1347 100644 --- a/google/cloud/pubsub/internal/subscriber_auth_decorator.cc +++ b/google/cloud/pubsub/internal/subscriber_auth_decorator.cc @@ -157,6 +157,31 @@ StatusOr SubscriberAuth::Seek( return child_->Seek(context, options, request); } +StatusOr SubscriberAuth::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 SubscriberAuth::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 +SubscriberAuth::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 SubscriberAuth::AsyncModifyAckDeadline( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/pubsub/internal/subscriber_auth_decorator.h b/google/cloud/pubsub/internal/subscriber_auth_decorator.h index c1aa0d55105d8..dd5e7ae8fc029 100644 --- a/google/cloud/pubsub/internal/subscriber_auth_decorator.h +++ b/google/cloud/pubsub/internal/subscriber_auth_decorator.h @@ -98,6 +98,18 @@ class SubscriberAuth : public SubscriberStub { grpc::ClientContext& context, Options const& options, google::pubsub::v1::SeekRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future AsyncModifyAckDeadline( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/pubsub/internal/subscriber_logging_decorator.cc b/google/cloud/pubsub/internal/subscriber_logging_decorator.cc index 36c29a87410ea..8fddcaa502212 100644 --- a/google/cloud/pubsub/internal/subscriber_logging_decorator.cc +++ b/google/cloud/pubsub/internal/subscriber_logging_decorator.cc @@ -208,6 +208,40 @@ StatusOr SubscriberLogging::Seek( context, options, request, __func__, tracing_options_); } +StatusOr SubscriberLogging::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 SubscriberLogging::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 +SubscriberLogging::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 SubscriberLogging::AsyncModifyAckDeadline( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/pubsub/internal/subscriber_logging_decorator.h b/google/cloud/pubsub/internal/subscriber_logging_decorator.h index 284c919884316..84ebbf3b0cdc9 100644 --- a/google/cloud/pubsub/internal/subscriber_logging_decorator.h +++ b/google/cloud/pubsub/internal/subscriber_logging_decorator.h @@ -98,6 +98,18 @@ class SubscriberLogging : public SubscriberStub { grpc::ClientContext& context, Options const& options, google::pubsub::v1::SeekRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future AsyncModifyAckDeadline( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/pubsub/internal/subscriber_metadata_decorator.cc b/google/cloud/pubsub/internal/subscriber_metadata_decorator.cc index b6be46fb594b8..3b73e6f47a358 100644 --- a/google/cloud/pubsub/internal/subscriber_metadata_decorator.cc +++ b/google/cloud/pubsub/internal/subscriber_metadata_decorator.cc @@ -172,6 +172,34 @@ StatusOr SubscriberMetadata::Seek( return child_->Seek(context, options, request); } +StatusOr SubscriberMetadata::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 SubscriberMetadata::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 +SubscriberMetadata::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 SubscriberMetadata::AsyncModifyAckDeadline( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/pubsub/internal/subscriber_metadata_decorator.h b/google/cloud/pubsub/internal/subscriber_metadata_decorator.h index ff404ef36bdca..038aece8772d9 100644 --- a/google/cloud/pubsub/internal/subscriber_metadata_decorator.h +++ b/google/cloud/pubsub/internal/subscriber_metadata_decorator.h @@ -98,6 +98,18 @@ class SubscriberMetadata : public SubscriberStub { grpc::ClientContext& context, Options const& options, google::pubsub::v1::SeekRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future AsyncModifyAckDeadline( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/pubsub/internal/subscriber_round_robin_decorator.cc b/google/cloud/pubsub/internal/subscriber_round_robin_decorator.cc index aeccb849ca329..f37db6725ee94 100644 --- a/google/cloud/pubsub/internal/subscriber_round_robin_decorator.cc +++ b/google/cloud/pubsub/internal/subscriber_round_robin_decorator.cc @@ -124,6 +124,25 @@ StatusOr SubscriberRoundRobin::Seek( return Child()->Seek(context, options, request); } +StatusOr SubscriberRoundRobin::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return Child()->SetIamPolicy(context, options, request); +} + +StatusOr SubscriberRoundRobin::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return Child()->GetIamPolicy(context, options, request); +} + +StatusOr +SubscriberRoundRobin::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return Child()->TestIamPermissions(context, options, request); +} + future SubscriberRoundRobin::AsyncModifyAckDeadline( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/pubsub/internal/subscriber_round_robin_decorator.h b/google/cloud/pubsub/internal/subscriber_round_robin_decorator.h index 907a70e3de251..e8388130a75a0 100644 --- a/google/cloud/pubsub/internal/subscriber_round_robin_decorator.h +++ b/google/cloud/pubsub/internal/subscriber_round_robin_decorator.h @@ -96,6 +96,18 @@ class SubscriberRoundRobin : public SubscriberStub { grpc::ClientContext& context, Options const& options, google::pubsub::v1::SeekRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future AsyncModifyAckDeadline( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/pubsub/internal/subscriber_stub.cc b/google/cloud/pubsub/internal/subscriber_stub.cc index d73e96a6b092c..5f59d6a634817 100644 --- a/google/cloud/pubsub/internal/subscriber_stub.cc +++ b/google/cloud/pubsub/internal/subscriber_stub.cc @@ -195,6 +195,41 @@ StatusOr DefaultSubscriberStub::Seek( return response; } +StatusOr DefaultSubscriberStub::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 DefaultSubscriberStub::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 +DefaultSubscriberStub::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 DefaultSubscriberStub::AsyncModifyAckDeadline( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/pubsub/internal/subscriber_stub.h b/google/cloud/pubsub/internal/subscriber_stub.h index 0522b32342ef2..0da1146a79dd5 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 @@ -98,6 +99,19 @@ class SubscriberStub { grpc::ClientContext& context, Options const& options, google::pubsub::v1::SeekRequest 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 AsyncModifyAckDeadline( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -114,8 +128,10 @@ class SubscriberStub { class DefaultSubscriberStub : public SubscriberStub { public: explicit DefaultSubscriberStub( - std::unique_ptr grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + std::unique_ptr grpc_stub, + std::unique_ptr iampolicy_stub) + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)) {} StatusOr CreateSubscription( grpc::ClientContext& context, Options const& options, @@ -177,6 +193,18 @@ class DefaultSubscriberStub : public SubscriberStub { grpc::ClientContext& context, Options const& options, google::pubsub::v1::SeekRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future AsyncModifyAckDeadline( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -191,6 +219,7 @@ class DefaultSubscriberStub : public SubscriberStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/pubsub/internal/subscriber_stub_factory.cc b/google/cloud/pubsub/internal/subscriber_stub_factory.cc index 9954626cf1cbe..5a6f4825a971a 100644 --- a/google/cloud/pubsub/internal/subscriber_stub_factory.cc +++ b/google/cloud/pubsub/internal/subscriber_stub_factory.cc @@ -57,16 +57,18 @@ std::shared_ptr CreateGrpcChannel( std::shared_ptr CreateDefaultSubscriberStub( std::shared_ptr channel) { return std::make_shared( - google::pubsub::v1::Subscriber::NewStub(std::move(channel))); + google::pubsub::v1::Subscriber::NewStub(std::move(channel)), + google::iam::v1::IAMPolicy::NewStub(std::move(channel))); } std::shared_ptr MakeRoundRobinSubscriberStub( google::cloud::CompletionQueue cq, Options const& options) { - return CreateDecoratedStubs( - std::move(cq), options, [](std::shared_ptr c) { - return std::make_shared( - google::pubsub::v1::Subscriber::NewStub(std::move(c))); - }); + return CreateDecoratedStubs(std::move(cq), options, + [](std::shared_ptr c) { + return std::make_shared( + google::pubsub::v1::Subscriber::NewStub(c), + google::iam::v1::IAMPolicy::NewStub(c)); + }); } std::shared_ptr MakeTestSubscriberStub( diff --git a/google/cloud/pubsub/internal/subscriber_tracing_stub.cc b/google/cloud/pubsub/internal/subscriber_tracing_stub.cc index ee630dbbdc301..d7aeab4ac18c8 100644 --- a/google/cloud/pubsub/internal/subscriber_tracing_stub.cc +++ b/google/cloud/pubsub/internal/subscriber_tracing_stub.cc @@ -196,6 +196,40 @@ StatusOr SubscriberTracingStub::Seek( child_->Seek(context, options, request)); } +StatusOr SubscriberTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.pubsub.v1.Subscriber", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr SubscriberTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.pubsub.v1.Subscriber", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +SubscriberTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.pubsub.v1.Subscriber", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future SubscriberTracingStub::AsyncModifyAckDeadline( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/pubsub/internal/subscriber_tracing_stub.h b/google/cloud/pubsub/internal/subscriber_tracing_stub.h index 2d915b2a95c68..c5ba84e088eff 100644 --- a/google/cloud/pubsub/internal/subscriber_tracing_stub.h +++ b/google/cloud/pubsub/internal/subscriber_tracing_stub.h @@ -98,6 +98,18 @@ class SubscriberTracingStub : public SubscriberStub { grpc::ClientContext& context, Options const& options, google::pubsub::v1::SeekRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future AsyncModifyAckDeadline( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/pubsub/testing/mock_publisher_stub.h b/google/cloud/pubsub/testing/mock_publisher_stub.h index 662aa5310876d..37adfec05711e 100644 --- a/google/cloud/pubsub/testing/mock_publisher_stub.h +++ b/google/cloud/pubsub/testing/mock_publisher_stub.h @@ -86,6 +86,22 @@ class MockPublisherStub : public pubsub_internal::PublisherStub { (grpc::ClientContext&, Options const&, google::pubsub::v1::PublishRequest const&), (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (grpc::ClientContext&, Options const&, + google::iam::v1::SetIamPolicyRequest const&), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (grpc::ClientContext&, Options const&, + google::iam::v1::GetIamPolicyRequest const&), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (grpc::ClientContext&, Options const&, + google::iam::v1::TestIamPermissionsRequest const&), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/pubsub/testing/mock_subscriber_stub.h b/google/cloud/pubsub/testing/mock_subscriber_stub.h index 41215664ca972..6560fc0f5acf6 100644 --- a/google/cloud/pubsub/testing/mock_subscriber_stub.h +++ b/google/cloud/pubsub/testing/mock_subscriber_stub.h @@ -121,6 +121,22 @@ class MockSubscriberStub : public pubsub_internal::SubscriberStub { (grpc::ClientContext&, Options const&, google::pubsub::v1::SeekRequest const&), (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (grpc::ClientContext&, Options const&, + google::iam::v1::SetIamPolicyRequest const&), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (grpc::ClientContext&, Options const&, + google::iam::v1::GetIamPolicyRequest const&), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (grpc::ClientContext&, Options const&, + google::iam::v1::TestIamPermissionsRequest const&), + (override)); }; class MockAsyncPullStream : public MockSubscriberStub::StreamingPullStream {